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 Do Session get invalidated when we close the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Do Session get invalidated when we close the browser" Watch "Do Session get invalidated when we close the browser" New topic
Author

Do Session get invalidated when we close the browser

Deepan Devadasan
Ranch Hand

Joined: Jan 25, 2007
Posts: 226
Hi Buddies,

Do Session get invalidated when we close the browser?

How long does the cookie JSESSIONID live...?

That should be out question...
Because the session id is the key for tracing back the original session...

am i correct...

please give your views?


Theepan Thevathasan
SCJP 1.4, SCWCD 1.4, SCMAD 1.0 SCBCD 1.3, MCP(.Net Frm 2.0 App Dev Fdn)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

No, the server has no idea that a browser window has been closed.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

How long does the cookie JSESSIONID live...?


That depends on the cookie's age. -1 signifies infinity. The session does not die when you close the browser


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Session are objects created at the container.untill you explicitly invalidate them or they timeout , untill then they remain in the server.


Rahul Bhattacharjee
LinkedIn - Blog
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
afaik, in Tomcat default timeout was 30 minutes = (30*60*1000=180000 milliseconds)
Under xxx-config.xml, for the server of tomcat, one should have entered this value in milliseconds, as 180000.
Deepan Devadasan
Ranch Hand

Joined: Jan 25, 2007
Posts: 226
Hi Friends...

Thanks for all your response..

That depends on the cookie's age

How can set the age of JSESSIONID cookie?
if it is custom cookie, of course with-- setMaxAge(milliSec)..
But JSESSIONID is maintained with the container?
And setMaxInactiveInterval(milliSec).. only set the age for the session object at the server end

Session are objects created at the container.untill you explicitly invalidate them or they timeout , untill then they remain in the server.

Rahul, you are correct...

So can i come to a conclusion that closing a browser doesn't have anything to do with the session...even the cookie related to sessionID(JSESSIONID cookie...........)

Thanks again for the reply posts
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Theepan Thevathasan:
Hi Friends...

Thanks for all your response..

Rahul, you are correct...

So can i come to a conclusion that closing a browser doesn't have anything to do with the session...even the cookie related to sessionID(JSESSIONID cookie...........)

Thanks again for the reply posts



Yes , browser close is not related to the HTTPSession objects created in the container , as the container would not know that the browser has been closed in the client end.but JSESSIONID is related to this issue as JSESSIONID is used to track requests from a single session.
Deepan Devadasan
Ranch Hand

Joined: Jan 25, 2007
Posts: 226
Tk Rahul,

Thanks for the replies...

I am clear now..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do Session get invalidated when we close the browser