I invalidate session when user click logout button. But when user close browser, how do I invalidate session by using servlet?
Asked
Active
Viewed 5,246 times
2 Answers
1
You can simply use either onunload (for IE) or onbeforeunload (for firefox) events of javascript to redirect your page to the url of the servlet (same as for Logout button) that invalidates the session.
<script>
function logout(){
window.location.href='sessionInvalidatorServlet';
}
</script
<body onunload="logout()">
.........
....

Satyendra
- 1,635
- 3
- 19
- 33