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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.