5 Replies Latest reply: Apr 6, 2012 12:49 PM by Paul Ferraro RSS

custom JSESSION cookie name, is this supported?

Aaron Bell Newbie

It's possible to use a cookie name other than JSESSIONID, as described in this article:




An individual Tomcat can set its own cookie name.


  1. Is there support in mod_cluster to use a custom cookie name like this, e.g. FOOSESSIONID?




  • 1. Re: custom JSESSION cookie name, is this supported?
    Paul Ferraro Master

    Yes, but there is some work involved.

    Within the container-spi module is the relevant method: org.jboss.modcluster.container.Engine.getSessionCookieName().

    You'll need to create a custom Engine and EngineFactory implementation and indicate the location of your EngineFactory within a file that can be found by the service loader.



    public class CustomEngine extends TomcatEngine { // You'll want to override the impl you currently use

        public CustomEngine(CatalinaFactoryRegistry registry, Engine engine, Server server) {

            super(registry, engine, server);




        public String getSessionCookieName() {

            return "FOOSESSIONID";




    public class CustomEngineFactory implements EngineFactory {


        public Engine createEngine(CatalinaFactoryRegistry registry, org.apache.catalina.Engine engine, Server server) {

            return new CustomEngine(registry, engine, server);




    Then bundle this class with a META-INF/services/org.jboss.modcluster.container.catalina.EngineFactory file that indicates the fully qualified class name of your CustomEngineFactory class.


    That should do it.

  • 2. Re: custom JSESSION cookie name, is this supported?
    Edwin Babadaglian Newbie

    Does this apply on a per 'LBGroup' basis? In other words, can each registered LBGroup declare its own distinct session cookie name or do all LBGroups have to employ the same name?




  • 3. Re: custom JSESSION cookie name, is this supported?
    Jean-Frederic Clere Master

    That could make sense to open a JIRA. jbossweb uses org.apache.catalina.JSESSIONID/jsessionid to set a different value, we should do the same.

  • 5. Re: custom JSESSION cookie name, is this supported?
    Paul Ferraro Master

    Actually, the mod_cluster-container-jbossweb and mod_cluster-container-tomcat6 modules already obtain the session cookie/paramater name from this system property (see the Engine.getSessionCookieName() and getSessionParameterName() methods).  The mod_cluster-container-tomcat7 module does not (and instead always uses a constant value).  Tomcat 7 allows this to be overridden per web application context - which is not compatible with mod_cluster since we send this value to the load balancer for all web apps (i.e. per Engine) - not per web app.