Hi
I want to destroy the session variables when the user closes the browser window. I tried the following code (found from the net) but it doesn't seem to work. It is not destroying the session variables and session_unset.php is being called even when I click on someother link (to load another page) on index.php.
What could be the problem?
index.php
<script src="redir.js" type="text/javascript"></script>
<body onUnload="redir();">
redir.js
function redir()
{alert("getting in");
window.location="http://localhost/session_unset.php";
//alert("trying to unset");
}
session_unset.php
<?php
ob_start();
@session_start();
header("Cache-Control: public, no-cache");
@session_unset();
@session_destroy();
@$_SESSION=array();
?>
any help is much appreciated