Index: java/org/apache/catalina/core/StandardContext.java =================================================================== --- java/org/apache/catalina/core/StandardContext.java (revision 883945) +++ java/org/apache/catalina/core/StandardContext.java (working copy) @@ -708,6 +708,13 @@ */ private boolean useHttpOnly = false; + + /** + * optional value configured to specify the default domain of + * the JSESSIONID cookie. + */ + private String defaultCookieDomain = null; + // ----------------------------------------------------- Context Properties @@ -5724,4 +5731,26 @@ return false; } + /** + * Gets the value of the default cookie domain for the JSESSIONID + * cookie, if configured, for this context. If the default cookie + * domain is not specified, this method will return null, and the + * default domain will not be set when the JSESSIONID cookie + * is created. + * + * @return value of the default cookie domain if configured, null otherwise. + */ + public String getDefaultCookieDomain() { + return defaultCookieDomain; + } + + /** + * Sets the value of the default cookie domain for the JSESSIONID + * cookie for this context. + * @param defaultCookieDomain the new value for the default domain for the + * JSESSIONID cookie + */ + public void setDefaultCookieDomain(String defaultCookieDomain) { + this.defaultCookieDomain = defaultCookieDomain; + } } Index: java/org/apache/catalina/connector/Request.java =================================================================== --- java/org/apache/catalina/connector/Request.java (revision 883945) +++ java/org/apache/catalina/connector/Request.java (working copy) @@ -2382,6 +2382,13 @@ } else { cookie.setPath("/"); } + + if (context != null) { + if (context.getDefaultCookieDomain() != null) { + cookie.setDomain(context.getDefaultCookieDomain()); + } + } + if (isSecure()) { cookie.setSecure(true); } Index: java/org/apache/catalina/Context.java =================================================================== --- java/org/apache/catalina/Context.java (revision 883945) +++ java/org/apache/catalina/Context.java (working copy) @@ -1073,6 +1073,24 @@ */ public void setTldNamespaceAware(boolean tldNamespaceAware); + /** + * Gets the value of the default cookie domain for the JSESSIONID + * cookie, if configured, for this context. If the default cookie + * domain is not specified, this method will return null, and the + * default domain will not be set when the JSESSIONID cookie + * is created. + * + * @return value of the default cookie domain if configured, null otherwise. + */ + public String getDefaultCookieDomain(); + + /** + * Sets the value of the default cookie domain for the JSESSIONID + * cookie for this context. + * @param defaultCookieDomain the new value for the default domain for the + * JSESSIONID cookie + */ + public void setDefaultCookieDomain(String defaultCookieDomain); } Index: webapps/docs/config/context.xml =================================================================== --- webapps/docs/config/context.xml (revision 883945) +++ webapps/docs/config/context.xml (working copy) @@ -237,6 +237,11 @@ + +

Set to what the cookie domain should be when creating + the JSESSIONID session cookie. Typically, this value + is not set.

+