Jump to content

Recommended Posts

I am not looking for coding just advice on how to do it.

 

I want to show users total time spent online. First i'll add a row into my users table, but then how would I go about storing the time in their?

 

When the online function deletes everyone from the list, make it add the total amount of seconds they were online? (That will be stored in a session or what?)

 

Thanks also should the row be a int 10, and then just store the seconds in their and increment it or wat?

Link to comment
https://forums.phpfreaks.com/topic/268970-total-time-a-user-spent-online/
Share on other sites

Storing time spent online is always an estimate. You can never tell when they leave the site, or if the human is still at the keyboard doing things. You can just say that every page load represents 30 seconds online, then keep a page load counter in the user table.

  • 1 month later...

With a simple Javascript setInterval() and some AJAX, you can make something that will suit your needs just fine.

I am not looking for coding just advice on how to do it.

 

I want to show users total time spent online. First i'll add a row into my users table, but then how would I go about storing the time in their?

 

When the online function deletes everyone from the list, make it add the total amount of seconds they were online? (That will be stored in a session or what?)

 

Thanks also should the row be a int 10, and then just store the seconds in their and increment it or wat?

 

A combo of Javascript, AJAX, and PHP should suffice. Use Javascript's setInterval() to "ping" the user's current state. If user has been inactive for x seconds/minutes/whatever, stamp that time and redirect to login page. With setInterval() you can get right down to (almost) exact time; however, that is just a waste. Really the setInterval() should work in hand with the allowable length of your current sessions.

 

My $0.02

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.