News for hackers. Stuff that matters.
Re:Show a real-time user count without any client-side Javas... by garethsprice on Sunday July 29, 2012 @02:55PM (#4309332)
This is similar to the COMET/AJAX push model: http://en.wikipedia.org/wiki/Comet_(programming)

As HTTP is stateless it's hard to tell when a user has disconnected, you can make the count more accurate by starting a session for each user then incrementing a "last_connected" timestamp by N seconds for each hit (can you tie this to each COMET update? Perhaps with JS?), then expiring any sessions that haven't been updated for a while. This is how a few popular CMS' (Drupal, Joomla) implement the "Who's Online" count.

There are no comments on this comment yet.