}
// Handle special case of ROOT context where cookies require a path of
// '/' but the servlet spec uses an empty string
- if (contextPath.length() == 0) {
- contextPath = "/";
+ // Also ensure the cookies for a context with a path of /foo don't get
+ // sent for requests with a path of /foobar
+ if (!contextPath.endsWith("/")) {
+ contextPath = contextPath + "/";
}
cookie.setPath(contextPath);
ServletRequest#getServerPort() and ServletRequest#getLocalPort() when
Tomcat is behind a reverse proxy. (markt)
</add>
+ <fix>
+ Ensure session cookie paths end in <code>/</code> so that session
+ cookies created for a context with a path of <code>/foo</code> do not
+ get returned with requests mapped to a context with a path of
+ <code>/foobar</code>. (markt)
+ </fix>
</changelog>
</subsection>
</section>