Reputation: 21
I am trying to invalidate the session when the user closes the browser without logging out. I tried using generated event unLoad
, but this event also fired when the user refreshes the page or presses the back button. So i want to invalidate the session when the browser closes.
If the user logs out normally I am invalidating the session using the code session.invalidate();
, but if the user closes the browser the session is not invalidated until container specific time out. How can I achieve this?
Upvotes: 0
Views: 616
Reputation: 8347
You can add window unload hook,
window.onbeforeunload = function(event) {
if (event) {
//code to invalidate session
}
}
Upvotes: 1