You do not have to do anything. As long as the request starting with the session, httpsTomcat marks the session cookie as secure.
I also looked to see if there was anything that officially documented this fact, but I could not find it. But this behavior, at least Tomcat 6.0.32 and higher.
org/apache/catalina/connector/Request.java, , , , secure cookie:
protected void configureSessionCookie(Cookie cookie) {
cookie.setMaxAge(-1);
Context ctxt = getContext();
String contextPath = null;
if (ctxt != null && !getConnector().getEmptySessionPath()) {
if (ctxt.getSessionCookiePath() != null) {
contextPath = ctxt.getSessionCookiePath();
} else {
contextPath = ctxt.getEncodedPath();
}
}
if ((contextPath != null) && (contextPath.length() > 0)) {
cookie.setPath(contextPath);
} else {
cookie.setPath("/");
}
if (ctxt != null && ctxt.getSessionCookieDomain() != null) {
cookie.setDomain(ctxt.getSessionCookieDomain());
}
if (isSecure()) {
cookie.setSecure(true);
}
}
UPDATE: , ..,
'secure' JSESSION id cookie