在启动项中增加org.apache.catalina.SESSION_COOKIE_NAME参数linux JAVA_OPTS=’-Dorg.apache.catalina.SESSION_COOKIE_NAME=yousessionname‘ win set JAVA_OPTS=”-Dorg.apache.catalina.SESSION_COOKIE_NAME=yousessionname“2、tomcat6和tomcat7修改方法相同

在Context容器标签上增加sessionCookieName参数<Context path=”/” docBase=”webapp” reloadable=”false” sessionCookieName=”yoursessionname”></Context>3、为啥这样就好用呢?

public final class Globals

  • The name of the cookie used to pass the session identifier back
  • and forth with the client.
    public static final String SESSION_COOKIE_NAME =
    public class StandardContext
  • The name to use for session cookies. null indicates that
  • the name is controlled by the application.
    private String sessionCookieName;
  • Gets the name to use for session cookies.
  • @return The value of the default session cookie name or null if not
  •      specified

public String getSessionCookieName() {
return sessionCookieName;

  • Sets the name to use for session cookies. Overrides any setting that
  • may be specified by the application.
  • @param sessionCookieName The name to use
    public void setSessionCookieName(String sessionCookieName) {
    String oldSessionCookieName = this.sessionCookieName;
    this.sessionCookieName = sessionCookieName;
    oldSessionCookieName, sessionCookieName);