Scropion Posted January 23, 2009 Share Posted January 23, 2009 I am trying to code a users total time logged in but I don't know how to do start!! Can anyone help me?? Link to comment https://forums.phpfreaks.com/topic/142065-total-time-logged-in/ Share on other sites More sharing options...
uniflare Posted January 23, 2009 Share Posted January 23, 2009 This can get more complicated the more accurate ou want to be, To start you off you want to record the unix timestamp, eg: time(); time() is the current time in seconds (since a specific date called the unix epoch). if you were able (through ajax maybe?) to tell when a user disconnected/closed their browser, you could use the first time() call taken away from a new time() call, would give you the secods that user was on the website. Though the easiest and i think best way would be to use a timer, since people sometimes leave a browser window on a website for days without closing it (or is it just me? lol), the could be online for 1 minute but it says a day, so you need a timeout, if the user is not active within 5 minutes of the last recorded activity, only add 5 minutes of activity (about 5 minutes to read the page). I hope this helps, Link to comment https://forums.phpfreaks.com/topic/142065-total-time-logged-in/#findComment-744066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.