Session time out java

This is regarding http session.

I'm having two applications which are running on two applications servers in two different ports. I login to a one application and then open a new tab from the same browser and login to the other application. Then what happen is it will timeout the first application's session.

In both applications http session is used wen login and logout.

What could be the root cause for the above scenario.

Any help would be appreciated in advance.

Upvotes: 1

Views: 282

Answers (2)

absin
absin

Reputation: 1166

You can manually try adding cookies

   HttpSession session = request.getSession();
   if (request.getParameter("JSESSIONID") != null) {
    Cookie userCookie = new Cookie("JSESSIONID", request.getParameter("JSESSIONID"));
    response.addCookie(userCookie);
   } else {
    String sessionId = session.getId();
    Cookie userCookie = new Cookie("JSESSIONID", sessionId);
    response.addCookie(userCookie);
   }

Upvotes: 2

JGlass
JGlass

Reputation: 1467

If both applications are the exact same application and their both running on the same server, but different ports - one session cookie is invalidating the other session cookie, I run into it all the time so if you want to accomplish what you're trying to do you can open one session in a "private" window and this will keep the sessions from being invalidated.

Upvotes: 3

Related Questions