How does a tomcat server identify clients for creating session id

2.1k views Asked by At

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 ?

2

There are 2 answers

2
JB Nizet On

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.

0
Ozum Safa On

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.