aspose file tools*
The moose likes Servlets and the fly likes Session  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session  " Watch "Session  " New topic
Author

Session

Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
Hi, I was wondering if a session is only specific for a browser. If we open up another browser in the same computer within the session's life time will another session be created?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Cameron Park:
Hi, I was wondering if a session is only specific for a browser. If we open up another browser in the same computer within the session's life time will another session be created?

If session tracking uses cookies (normally it does), a new session will be started only if the browser is really different (i.e. not a second copy of the very same browser).
If session tracking uses URL rewriting (normally only used when the browser refuses cookies), a new session will be started every time you go into the site.
- Peter
Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
<i>If session tracking uses URL rewriting (normally only used when the browser refuses cookies), a new session will be started every time you go into the site.</i>
From the same browser(ie. reload) and different session started every time or only different browser? If same browser, then I don't see "state" persisting throughout session.
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

A Session is an object that can be associated with a request. This is an implicit object that you get for free in JSP.
Now in order to get the behavior you want you need to understand what the session is really doing behind the scenes. If you understand what is happening then you can write your own mechanisms for tracking sessions.
As mentioned above, the session object is real just setting cookies or rewritting URL's. The default behavior is setting cookies and if that is not available the URL is rewritten.
Your applications behavior will be dependent on the browser. If the browser shares cookies with its other instances then their will only be one active session available using that browser. If you rewrite the URL (in theory you could code a mechanism that will POST the session id instead and get the same results) then the sessions will/can be seperate for each instance of the browser or even for different windows of the same instance of the browser. (I say CAN be different because I could cut and past the session id from one window into another and then have two windows with the same session)
Obviously if you are running two completely different browsers, say netscape and IE, they don't share cookies and you will have two sessions.
I hope this helps.


!_I_Know_Kung_Fu_!
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
If you are using IE, opening a new window with File->New or Control->N will always open a browser with the same internal thread.. ie, the session id will be the same. If you open a new IE browser using the desktop icon, you will get a different id.
For netscape, apparantly, multiple windows use the same internal thread.. So no matter how you open browser windows, all of them will share the same id.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session