Jump to content

Calculating Total Online Time Spent by Users

Recommended Posts

I have a forum script, i want to show the total online time spent by the users on the site, from registration till now, in their profiles...The problem is i am unable to figure out the logic behind calculating the online time... I tried one method, but it only calculates the time for a single session.. when the session expires or the user logs out, and when he logs in again the time starts from the beginning and the previous online time is dumped... :)Have a look here, click on any profile it shows the total online time spent by the user in their profiles...


I want the same thing.. Can someone tell me the logic or algorithm behind it.. Please..Thanx..

Link to post
Share on other sites

Well, you'd need to record it in a database each time they end their session. And each time you record it, add the time to the value that's already in the database.

Link to post
Share on other sites

Hmm will i need to create two fields in the user table? One with the current session online time and other with the total online time? And each time the session expires the value in the session online time will be added in the total online time... And the value of the total online time will be displayed in the profile...But there is a catch.. The total online time in the profile wont be updated in the real time cos it will only be updated when the session expires or ends... :)Correct me if i am wrong...Thanx.

Link to post
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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