1

I invalidate session when user click logout button. But when user close browser, how do I invalidate session by using servlet?

RP-
  • 5,827
  • 2
  • 27
  • 46
Ye Wint
  • 849
  • 3
  • 13
  • 20
  • 1
    http://stackoverflow.com/questions/9562411/how-to-invalidate-the-session-on-browser-close-in-the-jsf may helpful.. – RP- Nov 05 '12 at 12:54

2 Answers2

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
0

You can catch close page event as described this and send ajax request like when user make logout

Community
  • 1
  • 1
CAMOBAP
  • 5,523
  • 8
  • 58
  • 93