I think you need to use sessions for people as they login and out of the site, the number of sessions indicating how many people are online at a given time.
There is likely other ad-hock ways of doing this, specially if they are loging into a database, but I think sessions is likely the most efficient. Course I have never worked with sessions... so take that with a grain of salt
Cul