• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do sessions really work on client side

 
Aruneesh Salhotra
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ques : How do sessions really work on client side

I know how the sessions are handled on the server side. It basically sends JSESSIONID to the client in a cookie.

But how does it really work ? I see many posts on opening a new browser instance. I want to know
1. On what instances, a request to the server, makes a new session
2. On what instances, a request to the server, uses the same old JSESSIONID.
 
Jayesh Lalwani
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My understanding is this:-
The Webserver internally keeps a Map with the JsessionID as key and the Session object as value. So, whenever a request comes in that contains a valid JsessionID, the Webserver will load that Session and link it to the request object and call your servlet. If the request doesn't contain a valid JSessionID, the Webserver will create a new Session and link it to the request. Once a session expires the key value pair is taken out of the Map. So, any subsequent requests with an expired JSessionID will create a new session.

It's upto the browser to keep the cookie as long as it wants. I'm not sure, but I think the JsessionID is kept as long as the browser is open.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic