Friday, November 1, 2013

Multiple Tomcat instances on single server and session issue


When setting up 2 instances for Tomcat 6 on the same server, we got the issue of both are sharing sessions when both have same application context name. So if we logged into one instance, the session of the other will be expired.

The reason is cookie is stored by domain and cookie name, but not specified by server port. So both instances use the same JSESSIONID cookie name.

To fix it, we need to change the org.apache.catalina.SESSION_COOKIE_NAME parameter on java command.

We could do that easily with Tomcat bin/catalina.sh by adding that parameter to JAVA_OPTS:
JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.SESSION_COOKIE_NAME=JSESSIONID2"

No comments:

Post a Comment