Click here to Skip to main content
15,885,141 members
Articles / Web Development / ASP.NET

Force log off on browser exit

Rate me:
Please Sign up or sign in to vote.
4.97/5 (30 votes)
24 Sep 2012CPOL 43.8K   10  
Hello everyoneI have search the internet to somehow determine the best practice to do this and can't seem to come up with anything except the following but if anyone has a better idea please feel free to comment.Some background on projectThis particular website has a sensitive client...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
30 Jul 2010Roger Wright
I don't know how feasible this may be, but it occurs to me that you might include a client-side script to periodically whack the server in some way - a "keep-alive" signal. If the browser is closed or crashes, this signal would fail and you could initiate a logoff.
Please Sign up or sign in to vote.
3 Aug 2011Ganesan Senthilvel
I would strongly recommend to follow CWE/SANS TOP 25 Most Dangerous Programming Errors as the best practice solution for your questionSolution reference at: http://www.sans.org/top25-software-errors/2009/[^]
Please Sign up or sign in to vote.
30 Jul 2010Christian Graus
It's impossible. You can't do anything that is guarenteed to work, always. Instead, you need to turn off caching in all your web pages, and make each page check to make sure the user is logged in, or redirect to the login page. There is NOTHING secure about any system that does not do this. ...
Please Sign up or sign in to vote.
2 May 2011yesotaso
Found this while lolling around probably it doesnt matter anymore but just for reference...onbeforeunload Event (BODY, FRAMESET, window, ...)[^]I was wondering why bloody Groove Shark[^] asks me if I want to leave the page or not.
Please Sign up or sign in to vote.
20 Feb 2011Ed Nutting
Hi there,I don't know how well this works but when you close a browser it should end the session. When it does, if your using asp.net, the Global.asax class can help. There are methods in it that should be called when a session starts and ends which would allow you to force login/logout....
Please Sign up or sign in to vote.
15 Feb 2011Bloch Zahir
Hello,I think you can find help towards solving this issue your self with a little help from another post already on this website....Detect browser closing through clicks on the [X] buttonGood luck.
Please Sign up or sign in to vote.
4 Oct 2011sajithnet
debugger; function doUnload() { if (window.event.clientX < 0 && window.event.clientY < 0) { var objconfirm = confirm("Would you like to save changes made?") if (objconfirm == true) { ...
Please Sign up or sign in to vote.
17 Oct 2012manak chand
On design page writeonbeforeunload = javascript function();then call the webservice or pagemethod through jquery ajax methodand In the codebehind method query database and update the login table.This method will definatly work.. I had used it..
Please Sign up or sign in to vote.
22 Dec 2013Er. Tushar Srivastava
Hi friend,Actually, I looked at all the solutions and no doubt they all are great. But just a question? Is it really necessary for the system to keep the person logged in even if he has not been doing any considerable work. For example, I opened up the site, logged into it and then I...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions