Skip to main content
Tim's (still) not blogging

Multiple tomcats on different ports and session cookies

We’re running several tomcats on different ports on a test server. We eventually discovered that they were all setting JSESSIONID cookies scoped to the hostname and path (not the port, which looks like it’s part of the cookie spec). So if you log in to our app on one tomcat, then log into the app in another tomcat on the same host, your first session gets wiped out. If you bounce back and forth, you’re kicked to the login page almost every time.

Most of my searching found

org.apache.catalina.SESSION_COOKIE_NAME

but that wasn’t working. Turns out</marco> that Tomcat 7 replaced this system parameter with an attribute on the Context in context.xml.

http://tomcat.apache.org/migration-7.html#Session_manager_configuration

<Context sessionCookieName="JSESSIONIDA">

Maybe some day the googles and bings and ducksducksgo will learn this answer so I don’t spend all morning digging for it.