0

Possible Duplicate:
(PHP) how to destroy or unset session when user close the browser without clicking on logout?

How to expire the session when the browser window is closed

Community
  • 1
  • 1
Egglabs
  • 3,126
  • 10
  • 33
  • 48

3 Answers3

7

It will already unless you set a cookie. Don't need to do anything

Ashley
  • 5,939
  • 9
  • 39
  • 82
0
<script language="javascript">
function fnUnloadHandler() {
       // Add your code here Write Ajax code to invalidate session  
       alert("Are you sure to close ?");
}
</script>
<body onbeforeunload="fnUnloadHandler()">
<!-- Your page content -->
</body>
Mr.Chowdary
  • 3,389
  • 9
  • 42
  • 66
0

Another way is capture the window unload event in javascript call your session expire logic.

Thanks

Vicky
  • 9,515
  • 16
  • 71
  • 88