Arvind
Try a session variable. You can set them to expire after a specific amount of time - the default is 20 minutes I think. Each session gets a unique ID when it begins and you can just relate a session ID to the user and track them that way. when they use your logout function/page then you just use the session.abandon method to clear the variables for that session.
As for when they just close down the browser, the session variable will time-out after a certai period of time and then the variables are cleared - you can adjust this timeout period if need be (keep in mind not to make it too short or going to get a cup of
coffee for a few minutes will make it time out too). Or in an include file on every page just put your code for the unload event to call the session.abandon. That is probably easier and better in case the user closes the window in error and then tries to log on again right away.
hope that helps
Dave