lue: " + value.toString()); containerLog.debug("CrossSubdomainSessionValve: new Set-Cookie value: " + buffer); value.setString(buffer.toString()); } } } } /** Returns the last two parts of the specified request's server name preceded by a dot. * Using this as the session cookie's domain allows the session to be shared across subdomains. * Note that this implies the session can only be used with domains consisting of two or * three parts, according to the domain-matching rules specified in RFC 2109 and RFC 2965. * * <p>Examples:</p> * <ul> * <li>foo.com => .foo.com</li> * <li>www.foo.com => .foo.com</li> * <li>bar.foo.com => .foo.com</li> * <li>abc.bar.foo.com => .foo.com - this means cookie won't work on abc.bar.foo.com!</li> * </ul> * * @param request provides the server name used to create cookie domain. * @return the last two parts of the specified request's server name preceded by a dot. */ protected String getCookieDomain(Request request) { String cookieDomain = request.getServerName(); String[] parts = cookieDomain.split("\."); if (parts.length >= 2) cookieDomain = parts[parts.length - 2] + "." + parts[parts.length - 1]; return "." + cookieDomain; } public String toString() { return ("CrossSubdomainSessionValve[container=" + container.getName() + ']'); } }