This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes How to invaliddate session when browser Window is closed using [x] button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

How to invaliddate session when browser Window is closed using [x] button

Mahesh cosmolite
Greenhorn

Joined: Sep 19, 2011
Posts: 1
Hi Forum,

I want to invalidate session when browser is closed by end user using [x] button on LHS or double click on RHS.

Regards
Mahesh
Anuj Batra
Greenhorn

Joined: Sep 18, 2011
Posts: 24
I do not think there is a cross browser event handler available. but for IE onUnload works.
so place the function <body onUnload="function logout()">

function logout() {
<%session.inValidate();%>
}
jeya velan
Greenhorn

Joined: Feb 07, 2011
Posts: 9

Anuj Batra wrote:
function logout() {
<%session.inValidate();%>
}


You can not make a javascript function to execute a scriptlet.
You can call the logout URL using javscript which will do the work.
But you can't be sure.
There is no guarntee that onunload will execute properly.
olivier dutranoit
Ranch Hand

Joined: Aug 20, 2011
Posts: 81

let the session timeout do its work.
or put a < a href = ""> url to a logout servlet on the page.
do not try to capture browser events.
bad idea.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

This has been discussed dozens of times. Please SearchFirst.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to invaliddate session when browser Window is closed using [x] button
 
Similar Threads
Update database for logout when signout is not done properly
HttpSessionListener if browser is closed
How to remove the session value...
Clear firefox cookies on closing the window
Session Expired after Browser closing