Tomcat/Jboss 中自定义 SESSION_COOKIE_NAME

即把session id的cookie名从默认的JSESSIONID改成其它的什么名字。解决办法是把这些名字以system property方式注入:

Tomcat

http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html#Sessions


org.apache.catalina.SESSION_COOKIE_NAME

An alternative name for the session cookie. Defaults to JSESSIONID. Note that the Servlet specification requires this to be JSESSIONID. You should not rely on being able to change this.


org.apache.catalina.SESSION_PARAMETER_NAME

An alternative name for the session path parameter. Defaults to jsessionid. Note that the Servlet specification requires this to be jsessionid. You should not rely on being able to change this.

org.apache.catalina.SSO_SESSION_COOKIE_NAME

An alternative name for the single sign on session cookie. Defaults to JSESSIONIDSSO.

哪些版本支持:

This system properties based feature is only available in releases newer than Tomcat 5.5.28 and Tomcat 6.0.20.

=========================================================

JBOSS:

  官方文档没有说怎么配,但我们可以通过论坛和代码来找到办法。 代码有:

//org.apache.catalina.Globals in jbossweb.jar
public static final String SESSION_COOKIE_NAME = System.getProperty("org.apache.catalina.JSESSIONID", "JSESSIONID");
public static final String SESSION_PARAMETER_NAME = System.getProperty("org.apache.catalina.jsessionid", "jsessionid");

哪些版本支持? 不知道,反正5.1.0以后都支持

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.