Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue:The path of the cookie is changed. More sessions will be created for the same user #225

Open
javaofferss opened this issue Feb 10, 2022 · 0 comments · May be fixed by #227
Open

issue:The path of the cookie is changed. More sessions will be created for the same user #225

javaofferss opened this issue Feb 10, 2022 · 0 comments · May be fixed by #227

Comments

@javaofferss
Copy link

javaofferss commented Feb 10, 2022

图片

The path of the cookie is changed. More sessions will be created for the same user

old code:
protected Cookie createProxyCookie(HttpServletRequest servletRequest, HttpCookie cookie) {
String proxyCookieName = getProxyCookieName(cookie);
Cookie servletCookie = new Cookie(proxyCookieName, cookie.getValue());
servletCookie.setPath(buildProxyCookiePath(servletRequest)); //set to the path of the proxy servlet
servletCookie.setComment(cookie.getComment());
servletCookie.setMaxAge((int) cookie.getMaxAge());
// don't set cookie domain
servletCookie.setSecure(cookie.getSecure());
servletCookie.setVersion(cookie.getVersion());
servletCookie.setHttpOnly(cookie.isHttpOnly());
return servletCookie;
}

protected String buildProxyCookiePath(HttpServletRequest servletRequest) {
String path = servletRequest.getContextPath(); // path starts with / or is empty string
path += servletRequest.getServletPath(); // servlet path starts with / or is empty string
if (path.isEmpty()) {
path = "/";
}
return path;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant