Answered by:
how to end session on browser close

Question
-
User-639019811 posted
Hi all,
Is there is a way to kill the user's session on browser close?I searched for it but couldn't find right solution.Any help greatly appreciated
Thanks
Wednesday, November 9, 2011 10:12 AM
Answers
-
User229603173 posted
Check this links
http://stackoverflow.com/questions/1921941/close-kill-the-session-when-the-browser-or-tab-is-closed
http://forums.asp.net/t/1116238.aspx/2/10
http://dotnetspeaks.com/DisplayArticle.aspx?ID=12
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, November 11, 2011 2:30 AM
All replies
-
User-821857111 posted
You can use the jQuery unload() command to send an AJAX call to the server to kill the session.
Wednesday, November 9, 2011 11:46 AM -
User1296332936 posted
Look at the following links
http://www.codeguru.com/forum/showthread.php?t=386004
http://www.aspfr.com/codes/ASP-NET-SAVOIR-QUAND-UTILISATEUR-FERME-FENETRE-VIA_53700.aspx
Wednesday, November 9, 2011 12:23 PM -
User-639019811 posted
Mike,
Thanks for reply.
but i don't want to loose session if user hit backward or forward button,page reloads.Iwant to kill the session only if they close the browser.
Thursday, November 10, 2011 3:32 PM -
User1468581411 posted
There is no easy way to do it. The session is maintained on the webserver. What typically happens is that the serevr kills a session if there has been no activity for that session for 20 mins. You can try reducing that time out.
You might be able to do a javascript where when a user tries to close the browser, it sends out an xmlhttprequest to the webserver to close the session. But then if the user loses internet connection before closing the browser, the session will stay active until it times out.
Thursday, November 10, 2011 3:49 PM -
User229603173 posted
Check this links
http://stackoverflow.com/questions/1921941/close-kill-the-session-when-the-browser-or-tab-is-closed
http://forums.asp.net/t/1116238.aspx/2/10
http://dotnetspeaks.com/DisplayArticle.aspx?ID=12
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, November 11, 2011 2:30 AM