You cant actually be sure if he is online or not untill he loads another page from your server. This is because there is no connection between the server and the user other than page requests.
You sould set a timeout time for eatch session. Depending on the script this time should be variable. ie. A shopping chart script doesnt need as much time as an news posting script as the user is more likely to be browsing with more stedaly pase in the shopping chart. And in the news posting script he might use quite a while to write his article...
I hope this gives you a few pointers..
Andreas