Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 350
Viren Pushpanayagam Avatar asked Apr 11 '11 07:04

Viren Pushpanayagam


People also ask

How can we maintain session in Java Web application?

Since HTTP and Web Server both are stateless, the only way to maintain a session is when some unique information about the session (session id) is passed between server and client in every request and response. There are several ways through which we can provide unique identifier in request and response.

How user session is maintained in Web application?

Sessions are maintained automatically by a session cookie that is sent to the client when the session is first created. The session cookie contains the session ID, which identifies the client to the browser on each successive interaction.


1 Answers

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

What this is saying is

"Not directly. Most containers put each WAR in a separate classloader with the EAR classloader as their parent. Each app's sessions are separate. You can put something provided by the parent EAR in each session. If you need them to share something, make it a EAR function."

So, due to the each session being private, one web-app cannot see the other. So, your option is to bundle the two web apps in a single WAR file, to make them be able to share session data.

like image 177
Codemwnci Avatar answered Sep 24 '22 03:09

Codemwnci