Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: user login time

  1. #1
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts

    user login time

    How can I get the time of user login?

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,473
    Thanks
    13
    Thanked 361 Times in 357 Posts
    PHP Code:
    $_SESSION['login_time'] = $_SERVER['REQUEST_TIME']; 
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    New Coder
    Join Date
    Feb 2010
    Location
    God's Own Country
    Posts
    87
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    PHP Code:
    $_SESSION['login_time'] = $_SERVER['REQUEST_TIME']; 
    See I want to get the user's login time..if I use the above code whenver the page gets refreshed the time gets updated...How can I get the exact time of login...that is the time at which the user gets into the site.

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,473
    Thanks
    13
    Thanked 361 Times in 357 Posts
    why do you call that on every page load? it belongs only in the login script and it shouldn’t be reset once set.
    PHP Code:
    if (!isset($_SESSION['login_time']))
    {
        
    $_SESSION['login_time'] = $_SERVER['REQUEST_TIME']; 

    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Who's time are you talking about?
    Your time, your server's time, or your visitor's time?

    Your server might not be in your timezone, so you can
    force the server to use your city's timezone ...
    PHP Code:
    // Set the timezone to your city .. based on a valid city identifier
    // See:  http://www.php.net/manual/en/timezones.php
    date_default_timezone_set('America/Chicago'); 

    .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •