Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate custom JSESSIONID, based on some hash of user's data in order to replicate session

Is it possible to override Tomcat's embedded generator of JSESSIONID, to be able to create custom values of this cookie, based on user's login?

Why do I need this: I have a load balancer with "sticky sessions", configured to route requests with the same JSESSIONID to the same server, and I want to prevent situation, when same user can start two different sessions on different servers.

P.S: all this is about Amazon EC2

like image 652
Illarion Kovalchuk Avatar asked May 14 '10 11:05

Illarion Kovalchuk


People also ask

How is the Jsessionid generated?

JSESSIONID is a cookie generated by Servlet containers and used for session management in J2EE web applications for HTTP protocol. If a Web server is using a cookie for session management, it creates and sends JSESSIONID cookie to the client and then the client sends it back to the server in subsequent HTTP requests.

Where is Jsessionid stored?

Sessions are stored on the server. They can be referenced by a cookie or parameter (JSESSIONID.) It is better not to use the parameter because then the session id shows up in logs, etc and someone could potential hijack it. 2) The session expires after a set period of inactivity (usually 30 or 60 minutes.)


1 Answers

There is a better way to do this: See the tomcat manual on session replication in cluster

like image 61
Bozho Avatar answered Sep 22 '22 01:09

Bozho