• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clearing httpsession on window close, techniques?

 
Alok Pota
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody have a bag of tricks to have the session invalidated when closing the browser window.
One of the tricks that I know:
Have a hidden iframe and have it navigate to the url that invalidates the session when window closes.
 
Sanjeev Kaushik
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use the "onUnload" event of the body tag. Onunload you can try call the server side, which can invalidate the session object.
Hope this helps.
Sanjeev
 
Alok Pota
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, but onUnload also gets called when I get out of the page through valid exit points (say Clicking the Cancel button).
There needs to be an onClose event for the DHTML window object.
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
Can U elaborate on the first technique which U suggested...
Paste the code if necessary
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anybody pls answer my previous posting pls
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ONLY way to notify the server that the browser is no longer there or is moved to another site is to put some Javascript in the onunload event for the body tag of the page.
Here you can have the browser then call a servlet on the server which can invalidate the session.
As said, there is a potential problem in that it also gets called when you move to another page on your site, but I think there are ways to circumvent that.
I've never used the function myself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic