If it's users who have accounts on your site, this is fairly
straightforward.
What you would do, is that when a user logs in, you insert
their details into a new table called something like "whoIsOn" and
then query this table to get the amount of records and times etc
they have been logged in for. When the user session ends, you
simply delete this record from the table.
It might be an idea to also put something in place to check
for last activity because a user might leave the computer for a
long time without actually logging out. So on your query, you could
have a column in the table that updates on every page they visit
called "lastModifiedTimeDate" and then compare that to the current
time. If it's longer than say an hour, you can probably be sure
that they haven't been looking at the same page for an hour without
clicking on something and you could therefore delete this record.
I dunno, I've never done it, but I imagine uing a temp table
like this would be the best solution.
Good luck.
Mikey.