This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

Catching the browser close action

 
Fawad Ali
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,
I want to catch the browser close button action. Let me explain the scenario first. When a user clicks on the close button of a browser, I want to send an ajax call to set his loginStatus to false in the database. I can do it with the js event of onbeforeunload, but that has too many problems. The biggest being, when I navigate to some other site say google.com, it will set the login status to false, but then when I click on the back button, the session should remain there (ideally), but its logged out.

Any ideas on how to hunt for the solution?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
This has been discussed dozen and dozens of times. Please search for previous discussions. The bottom line is that there is no way to determine when the browser has been closed.
 
    Bookmark Topic Watch Topic
  • New Topic