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,082
  • 10
  • 32
  • 46

3 Answers3

7

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

Ashley
  • 5,889
  • 9
  • 37
  • 78
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,339
  • 9
  • 37
  • 64
0

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

Thanks

Vicky
  • 9,379
  • 15
  • 68
  • 88