Page 1 of 1

You have been logged in for xx:xx

Posted: Tue May 10, 2011 3:28 pm
by sven
Hello, so it's time for me to make my first thread here, in hope of getting some help with this.

So my question is following,
I'd like to have a clock that says "You have been logged in for" is this somehow possible to make in php, and if so how?

thanks

Re: You have been logged in for xx:xx

Posted: Tue May 10, 2011 4:27 pm
by jacek
When they log in you can store the current time in the session that you presumably are creating ?

Then take this away form the current time on each page load to get the number of seconds they have been logged in.

Re: You have been logged in for xx:xx

Posted: Tue May 10, 2011 4:58 pm
by sven
jacek wrote:When they log in you can store the current time in the session that you presumably are creating ?

Then take this away form the current time on each page load to get the number of seconds they have been logged in.
How would I store the time in session?

Re: You have been logged in for xx:xx

Posted: Tue May 10, 2011 4:59 pm
by Tino
$_SESSION['last_login'] = time();
You would set that whenever the user logs in.

Re: You have been logged in for xx:xx

Posted: Wed May 11, 2011 6:48 am
by bowersbros
and every page ave
$current_time = time();

echo "Time logged in: " .($current_time -  $_SESSION['last_login']);