Changing cookie JSESSIONID name

前端 未结 7 1859
自闭症患者
自闭症患者 2020-12-04 21:18

I have a requirement of having to run multiple tomcat server in single physical box. While accessing these from a browser, when user switches between the applications, it re

相关标签:
7条回答
  • 2020-12-04 21:38

    Everything is much simpler with Servlet API 3.0.

    Now you can configure it in your web.xml:

    <session-config>
        <cookie-config>
            <name>MY_JSESSIONID_YAHOOOOOO</name>
        </cookie-config>
    </session-config>
    

    That's it!

    0 讨论(0)
  • 2020-12-04 21:44

    I found it in Tomcat at /tomcat/conf/server.xml

    server.xml

    <Engine name="Catalina" defaultHost="localhost" jvmRoute="instanceName">
    

    5D33F755D8D75EF7C8E840.instanceName

    0 讨论(0)
  • 2020-12-04 21:45

    I don't think it's possible at this point - see https://issues.apache.org/bugzilla/show_bug.cgi?id=42419

    The last entry states "This has been fixed in 5.5.x and will be included in 5.5.28 onwards" - which is the next point release - 5.5.27 is the current release.

    0 讨论(0)
  • 2020-12-04 21:50

    Not 100% sure if this will work, but you can use the jvmRoute attribute, which is generally used in a load-balanced/clustered environment for the load balancers to be able to tell the nodes apart. Example:

    <Engine name="Catalina" defaultHost="localhost" jvmRoute="node1">
    

    This will end up generating a JSESSIONID value that looks like "ABCDEF123456.node1".

    Documentation link.

    0 讨论(0)
  • 2020-12-04 21:54

    Tomcat 7 moves this from org.apache.catalina.SESSION_COOKIE_NAME to an attribute on the main <Context> config. http://tomcat.apache.org/migration-7.html#Session_manager_configuration

    0 讨论(0)
  • 2020-12-04 21:57

    The following works for me on Tomcat7 in the context.xml file:

    <Context path="/yourApp" sessionCookieName="custom_session_id">
    
    0 讨论(0)
提交回复
热议问题