How to maintain the same session id in multiple Java web applications

How do I maintain the same session ID for multiple web applications on a Jboss server?

+7
source share
2 answers

Take a look at this post for a similar question. Accessing a session of another web application

What does it mean:

"Not always. Most containers put each WAR in a separate class loader with the EAR class loader as the parent. Each application session is separate. You can put something provided by the parent EAR in each session. If you need them to share something then make it an EAR function. "

So, because each session is private, one web application cannot see another. So your option is to link two web applications in one WAR file so that they can share session data.

+3
source

I searched for this recently and found a solution.

If you just want to share the identifier, you can use the following configuration in web.xml. Given that you are using servlet 3.0.

<session-config> <cookie-config> <path>/</path> </cookie-config> </session-config> 

This will save the jsessionid cookie with the // path, which will be used for all web applications. Here's how JBoss 4 did it.

0
source

All Articles