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.
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
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: