How to find the closing of an application window without ' log out' the session .This is to prevent the user from directly going to the previous session. In such cases, the user session should end and direct the user to the login page.
views:
34answers:
2
A:
It's a very common problem with websites when you don't want the user to remain "logged in" although the user has left the site.
There are several ways you can achieve that, but IMHO any 100% reliable.
For example you can call an ajax function when the body onunload event
is fired, and that function could remove the current user session.
It's only an idea.
Zheileman
2010-07-12 13:50:06
onunload is fired even when the user goes from one page to another (http://api.jquery.com/unload/) - so the AJAX can't yet remove the user session, only 0.5 sec later if no other request came from this session. Seems to get hairy.
giraff
2010-07-13 20:32:18
A:
The normal/easiest way to solve this is to set Session Expiration to a rather low value (10-20 minutes).
Alternatively, you could remove a session after only 30 seconds of inactivity, and sending a little ajax request every 5 seconds (which obviously stops when the application window/tab is closed).
giraff
2010-07-13 20:47:21