Users Online... how does it work?

software development

#1

Sorry, I know this question is kind of general and therefor probably a bit hard to address.

How do those “currently online” counters work? The things you see off at the side on Joomla and PHPnuke, or just about any forum. Does it like update a database every time the page is accessed? I don’t think that they usually count crawlers though, so it doesn’t seem like that would work to me. And aside from that, then how would they know if the user left the page… please explain the method if anybody here knows.

Thanks a whole bunch.


#2

Well the good thing about open source is you can always take a look at the code and see how others do it. So all you need to know is how to read code :wink:

Generally each visitor gets assigned a session that is tracked by a cookie or URL parameter - especially if they have to log in. So then all the software has to do is count “recent” sessions. One could stop counting a session when the visitor logs out or after a timeout period has elapsed.

And if you are looking for a PHP tutorial, Google is your friend - all you have to do is search for “online counter PHP” and the results lead you to:

Build a People Online Counter with PHP and MySQL

Cool huh?

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


#3

[quote]And if you are looking for a PHP tutorial, Google is your friend - all you have to do is search for “online counter PHP” and the results lead you to:

Build a People Online Counter with PHP and MySQL[/quote]
This helped a lot, thanks.