Possible Duplicate:
Check if user is offline
I’m building a community website. Users will login and logout as usually.
I use the attribute status online/offline to set the user’s status. But what if a user just clicks the X button or disconnects otherwise without logging out?
it shows login status.How i get to know user is currently online or not ?
You have three options:
You can assume the user is offline if they don’t load a new page within a specific period of time (e.g. 10 minutes). This would be done by keeping a “last page load time” for each user on the server.
You can have a script on your pages that fires off an AJAX call every so often to tell the server “I’m still here” – this would use the same logic as #1, but would be somewhat more reliable.
You can use a page-unload AJAX call to tell the server when the browser is unloading the page, and mark the user as offline until they load another page.