Idr where I read it, but today I was reading up on making custom session handlers using PHP and MySQL, and they mentioned that one of their most useful purposes is for something like a "Users Online" script.
When a person visits your site, it stores a session in the database. It will remain there until they close their browser, at which point it unsets the session. Then 5 minutes after they have closed their browser, it deletes the session from the database. You would call the number of users online, by counting the number of sessions in the database.
http://www.zend.com/zend/spotlight/code-gallery-w...pen=1&anc=0&view=1
A page on custom sessions.