You have been logged in for xx:xx

Ask about a PHP problem here.
Post Reply
sven
Posts: 8
Joined: Tue May 10, 2011 2:29 pm

You have been logged in for xx:xx

Post 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
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: You have been logged in for xx:xx

Post 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.
Image
sven
Posts: 8
Joined: Tue May 10, 2011 2:29 pm

Re: You have been logged in for xx:xx

Post 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?
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: You have been logged in for xx:xx

Post by Tino »

$_SESSION['last_login'] = time();
You would set that whenever the user logs in.
Please check out my CodeCanyon items.
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: You have been logged in for xx:xx

Post by bowersbros »

and every page ave
$current_time = time();

echo "Time logged in: " .($current_time -  $_SESSION['last_login']);
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Post Reply