简体   繁体   中英

How can I share session in two web application in different web servers?

I have the following problem. The customer have a Java EE web application running in EAServer 5.5.0 with a custom loggin. The loggin is very simple, when the application validates the credentials entered by the user through a web page, stores the user name and profile in a session variable. That way the application knows if the session is still alive. Now, the customer have another Java EE web application running in jboss server 7.1 and wants when the user log in the web application running on EAServer, at same time login in the application running in Jboss Server whitout any further steps.

My first idea was send the credentials via ajax call from EAServer to Jboss web application and stored the credentials in session, same way as the EAServer do. That seems to works fine on Internet Explorer, but in chrome or firefox the ajax call is done and the session variables are created in jboss, but when the user tries to see any view on the Jboss Application the session variables just gone.

Can somebody please tell me what is the best way or practice to do this? or what kind of problem I'm facing whit chrome and firefox that doesn't keep the session variables after ajax call?

One way you can do is the single sign-on that Leonardo Luiz suggested in the comment.

But I have another suggestion. Just install Redis and use it as a session store. This is very standard nowadays and it's broadly used in Ruby on Rails , NodeJs and Java as well.

Some libraries that might get you going:

Spring Session

Tomcat Redis Session Manager (I know you are using different servlet server, but still you can take a look to get the idea)

Or you might opt to use memcached. In that case you might use:

memcached-session-manager

The feature you need is called Single sign-on . I believe it's better to integrate an existing solution on your environment than create a custom one.

I already used two solutions for that:

It will not be a ease task and requires some knowledge of security concerns.

If you really wanna to create a custom solution there is some information here: http://merbist.com/2012/04/04/building-and-implementing-a-single-sign-on-solution/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM