3

I need to learn how a tomcat server identify different hosts to create unique sessions. Does it do it according to Ip ?

Based on answer to this question, I want to be able to create multiple sessions for single client, on a server which uses simply httpServletRequest.getSession() to create new sessions. Is possible to give a predefined session Id to a server, so that that server creates that new session bound to that session Id ?

Ozum Safa
  • 1,458
  • 2
  • 15
  • 27
  • It doesn't do it according to ip, it does it according to server scheme and name. You can have several different host names on the same ip address and you will get different sessions for each host if your client moves between them. You will also get different sessions for the same host if the scheme changes, eg if your client moves from http into https. – mwarren Nov 11 '14 at 08:50

2 Answers2

4

It doesn't do any identification. Each time a request comes in and you ask for a session to be created, it creates one. The generated session ID is sent to the browser in a cookie, and the browser sends back this cookie for all subsequent requests, which allows Tomcat to find the associated session.

I can't really understand what you're trying to achieve. A session doesn't identify a server. It identifies a specific client of a web app. Each client has its own session ID. Assigning a session ID to a server doesn't make much sense to me.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
0

Turns out if you dont have any cookie, you are treated as a brand new user, and it gives you a new cookie. So not sending a cookie is enough to obtain another session Id.

Ozum Safa
  • 1,458
  • 2
  • 15
  • 27