Page 1 of 1

Users online

Posted: Thu Nov 24, 2005 3:30 pm
by Ree
To be able to display currently active users (say, in a forum) you need to set that activity in the db somehow. If some user leaves the forum (closes his browser, for example), how would you know he had became inactive? You won't be able to update db, because you won't know he actually left at that moment. The solution I could think of is simply logging user's clicks and saving timestamps in the db, and then when you need to check active users, you compare current timestamp with the latest one of each user - if the difference is larger than some time interval, the user is considered inactive, otherwise he's considered active. Is that how you do it, or is there a better way? How does phpBB do this?

Posted: Thu Nov 24, 2005 3:38 pm
by neophyte
phpBB and other "who's online solutions" store sessions information in a db. Included in that info is the date of last page request. You just execute a query of who's online within a give period of time usually 10-15 minutes.

Posted: Thu Nov 24, 2005 10:18 pm
by Ambush Commander
For more fine grained access you can program AJAX to cause users to phone into the server while their server is still on. At the extreme end you implement a fat-client that *must* phone back to the server.

But neophyte's solution is the most commonly deployed.

Posted: Fri Nov 25, 2005 1:03 am
by josh
AJAX solutions are usually more accurate, with 'traditional' users online systems working off unique IPs (to determine guests, not registered users) a google bot crawl can trick your system into thinking there is 100's of extra users on the system since the bots come from multiple IPs, I've had it happen to me a few times.

Posted: Fri Nov 25, 2005 12:02 pm
by Burrito