TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How To Clear The Session?
Ghanashyam Nayak
Apr 29, 2020
4.5
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
How To Clear Session When The User Closes a Window Or Browser?
<script type=
"text/javascript"
>
function
window.onbeforeunload()
{
var
XMLHttpRe;
try
{
//For "Firefox", "Opera 8 Or Higher" & "Safari" Browsers
XMLHttpRe=
new
XMLHttpRequest();
}
catch
(e)
{
// Internet Explorer Browser
try
{
XMLHttpRe=
new
ActiveXObject(
"Msxml2.XMLHTTP"
);
}
catch
(e)
{
try
{
XMLHttpRe=
new
ActiveXObject(
"Microsoft.XMLHTTP"
);
}
catch
(e)
{
alert(
"Your Browser Does Not Support!"
);
return
false
;
}
}
if
(event.clientX > document.body.clientWidth && event.clientY < 0 || event.altKey)
{
XMLHttpRe.open(
"GET"
,
"exit.aspx"
,
false
);
XMLHttpRe.send();
}
}
}
</script>
How To Clear The Session
Next Recommended Reading
Clearing A Array And Reduce Array Elements, Flatten The Nested Array