addCookie(createServletCookie(webApp));
}
protected Cookie createServletCookie(WebApp webApp)
{
SessionManager manager = webApp.getSessionManager();
String cookieName;
if (_request.isSecure())
cookieName = manager.getSSLCookieName();
else
cookieName = manager.getCookieName();
CookieImpl cookie = new CookieImpl(cookieName, _sessionId);
cookie.setVersion(manager.getCookieVersion());
String domain = webApp.generateCookieDomain(_request);
if (domain != null)
cookie.setDomain(domain);
long maxAge = manager.getCookieMaxAge();
if (maxAge > 0)
cookie.setMaxAge((int) (maxAge / 1000));
cookie.setPath(manager.getPath());
if (manager.getComment() != null)
cookie.setComment(manager.getComment());
cookie.setPort(manager.getCookiePort());
if (manager.isSecure()) {
// server/12zc (tck) vs server/01io (#4372)
/*
if (_request.isSecure())
cookie.setSecure(true);
*/
cookie.setSecure(true);
}
else if (manager.isCookieSecure()) {
if (_request.isSecure())
cookie.setSecure(true);
}
if (manager.isCookieHttpOnly())
cookie.setHttpOnly(true);
return cookie;
}