File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Session Expired after Browser closing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Expired after Browser closing" Watch "Session Expired after Browser closing" New topic
Author

Session Expired after Browser closing

Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 224
All,
I would like to know that
how to expire the user's session when the browser(IE,FF,opera etc) gets closed(exited) directly i.e pressing Close(X) button on the top-right side.

How to determine that event?

We are able to expire session if user refreshes the page.But unable to find the solution for this case.


Thank you.
Regards
Baseet Ahmed

Knowledge is not what memorised.
Knowledge is what give benefits
(Imam Shafai)
Sudhakar Duraiswamy
Ranch Hand

Joined: Dec 20, 2007
Posts: 43
hi,
Can i know how is the what kind/on what basis the session validation is done in you application.


One can use session cookies to identify a particular session of the browser.
If the browser is closed ,the corresponding session cookies are destroyed


Sudhakar
SCJP 5.0 93%| SCWCD (prep. ongoing))
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is no reliable way to do this.
It is better to allow the session to time out.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 224
Sudhakar,

We also came to know that using cookies we can check it.
But the case is, we are not using Cookies in our application.
Instead we are making the session id using Random class and some manual logic.

Any other alternative to find out the solution for mentoned problem.

Regards
Baseet Ahmed

Knowledge is not what memorised.
Knowledge is what give benefits.
(Imam Shafai)
Rishi Trehan
Greenhorn

Joined: Aug 03, 2011
Posts: 1
Baseet Ahmed wrote:All,
I would like to know that
how to expire the user's session when the browser(IE,FF,opera etc) gets closed(exited) directly i.e pressing Close(X) button on the top-right side.

How to determine that event?

We are able to expire session if user refreshes the page.But unable to find the solution for this case.


Thank you.
Regards
Baseet Ahmed

Knowledge is not what memorised.
Knowledge is what give benefits
(Imam Shafai)






Hi Imam Shafai

How to expire a session after refresh the window..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61603
    
  67

Why on earth would you want to expire the session just because the user refreshed the window?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
Bear Bibeault wrote:Why on earth would you want to expire the session just because the user refreshed the window?

Bear,
I have seen some internet banking sites doing that. If you click on the refresh button/ back button of the browser a message is displayed saying that "because of security reasons back and refresh are disabled" and you will be automatically logged out of the site. I did not understand the reason for that though. Are back and refresh a threat to security in a secure web-app??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Expired after Browser closing