Jump to content

Total login time


abdfahim

Recommended Posts

Create a timestamp when they log in and another when they log out. When they log out subtract the first timestamp from the second, giving you the amount of seconds they were logged in for then update the database with that. You could then use date() (I think) it may be time(), to change the timestamp into something more readable.

 

I'm not sure if it's date() or time() or maybe even something else, working with dates and times in PHP is something I've not entirely grasped myself yet, someone else could probably help you more...

Link to comment
https://forums.phpfreaks.com/topic/77128-total-login-time/#findComment-390606
Share on other sites

What I usually do is have a "last_login" (date_time) in my users table. When the user logs in I just update this with NOW(). If you want to calculate how long your users have been logged into your site check this out:

http://www.bytemycode.com/snippets/snippet/736/

I wrote that for a few of my sites and it works well.

 

Hope that helps!

-Chris

Link to comment
https://forums.phpfreaks.com/topic/77128-total-login-time/#findComment-390625
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.