Okay,
here is a method which might require a bit more work, but it would be very useful and let administrators tracks users as well.
Basically, add a field in your database table like: last_accessed
So what you do is: on each page, call a function that would update this field using the current timestamp.
For the users online, do an SQL query that would select users that have the last_accessed time no more than say.... 5 minutes.
Let me give you a scenario:
step 1: user logs into site
step 2: the authentication system records the timestamp of the time when the user logged in
step 3: user goes to ... say... news.php
step 4: news.php recognized user and updates his/her field in the database and puts in the current timestamp
step 5: user goes to some other page
step 6: that other page records the timestamp of when they arrived to that page
NOW for the "users online". do something like this:
$sqlQuery = "SELECT count(*) as numusers FROM users_table WHERE last_accessed > " . (time() - 300);
Basically, the above query will return a count of users who have accessed a page on the site within the last five minutes (300 seconds).
does this make sense?
-sridhar