Portal Home > Knowledgebase > Articles Database > users online script


users online script




Posted by ryan14, 07-23-2009, 11:59 PM
i have been looking at some users online php scripts that when embedded into your website it can tell you how many users are currently browsing your website. My question is, how can the script tell when users leave the website? When a person closes their web browser does it send some info to the website to tell it it's going offline?

Posted by mwatkins, 07-24-2009, 01:51 AM
Rather than answering part of the question "When a person closes their web browser does it send some info to the website to tell it it's going offline?" might I recommend you download tcpwatch: http://freshmeat.net/projects/tcpwatch/ Set it up as a proxy so you can watch the browser to server communications between your client browser and a site you are interested in emulating. Note whether there is or is not any traffic when you switch pages , close tabs or close browser window, or otherwise leave.

Posted by JulesR, 07-25-2009, 10:29 AM
I believe for the most part, these "Users Online" scripts simply add the browsing user to a database and attach a timestamp to their requests, effectively just a "last access" time. If the "last access" time exceeds a particular number, they assume the user is offline and clear the record(s) within the database. The other alternative way to track (which is often much faster) is to count the number of session files in your sessions folder. If you're using shared hosting, you will need to create a seperate sessions folder otherwise you'll end up counting sessions that don't belong to your site. Check this article for lots of great information on how to set this up: http://www.devarticles.com/c/a/PHP/T...line-With-PHP/



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Current CPU ussage? (Views: 660)
Windows Syslog? (Views: 688)