Hi,
I am working on asp.net web application.I want to kill the session when the user closes the browser tab without signout.
I am using
function
CheckBrowser() {
if (clicked == false) {
xmlHttp = GetXmlHttpObject();
xmlHttp.open(
"GET", "SessionClear.aspx", true);
xmlHttp.onreadystatechange =
function () {
if (xmlHttp.readyState == 4) {
// alert(xmlhttp.responseText)
}
}
xmlHttp.send(
null)
if (browser == "Netscape") {
window.location =
"SessionClear.aspx";
alert(
"Browser Terminated");
openInNewWindow();
}
}
else {
//alert("Redirected");
clicked =
false;
}
}
function GetXmlHttpObject() {
var xmlHttp = null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp =
new XMLHttpRequest();
}
catch (e) {
//Internet Explorer
try {
xmlHttp =
new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
xmlHttp =
new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
<
body bgcolor="#F2F2F4" style="width: 99%; text-align: center;"
onunload
="CheckBrowser()" onclick="clicked=true;"
>
I have this code in my masterpage.the code is working good.My only problem is it is working for the browser back button also. I just wants to kill the session when the browser tab closed not for the back button.
Please help me anyone.
Thanks.