Checking user sessions, how?



How do I check the users that are on my pages, when they enter and when they leave? Are there some session variables that signifies unique users on the site / or when they go offline?
I have tried to search the net on this topic but without luck.
Hope someone can help.
the best ways to track users would be to keep a database with the session ID and time in a table.

everytime the user does something on the webpage it updates the current time associated with that session_id.

also everytime the script is run you can have it delete all those that are older than 5 mins. This will give an approximation on who has been active within the last five minutes

PHP is a serverside language. To my knowledge there is no way to see which sessions are still active because there is no constant connection with the clients computer. You can do it in java with a server/client model but most servers do not allow you to run your own daemon. So the only way you can find out who is active or not is to set a timeout.