I´m working on a webapp MVC and want to know when the user closes the browser tab, in order to destroy his session. I´m working with jsp (html, js) and java for the internal code. Some ideas?
Asked
Active
Viewed 52 times
2 Answers
0
You can use window.onunload
function from javascript
window.unload = function () {
//doSomething
}
or add an eventlistener to the unload
event of the window in following way:
window.addEventListener('unload', function() {
// doSomething
})";
Have a look at the full docs on more details onunload and unload event.

Pranay Tripathi
- 1,614
- 1
- 16
- 24
0
You can use this link and put your ajax session destroy there -> Run JavaScript code on window close or page refresh
after the Ajax call, you can easily get the session and invalidate/remove it!

Mehdi
- 3,795
- 3
- 36
- 65