View Full Version : user login time

03-10-2010, 07:16 PM
How can I get the time of user login?

03-10-2010, 07:52 PM
$_SESSION['login_time'] = $_SERVER['REQUEST_TIME'];

03-10-2010, 08:58 PM
$_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.

03-10-2010, 09:02 PM
why do you call that on every page load? it belongs only in the login script and it shouldn’t be reset once set.

if (!isset($_SESSION['login_time']))
$_SESSION['login_time'] = $_SERVER['REQUEST_TIME'];

03-10-2010, 09:33 PM
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 ...

// Set the timezone to your city .. based on a valid city identifier
// See: http://www.php.net/manual/en/timezones.php