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
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
<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>
Another way is capture the window unload event in javascript call your session expire logic.
Thanks