何もする必要はありません。セッションを開始するリクエストがhttps
である限り、TomcatはセッションCookieをsecure
とマークします。
また、その事実を正式に文書化したものがあるかどうかを確認しましたが、見つけられませんでした。しかし、それは少なくともTomcat 6.0.32以上の動作です。ここで
は、メソッドの最後に、要求が安全であるかどうかをチェックし、
org/apache/catalina/connector/Request.java
からのコードであり、それがある場合は、クッキーの
secure
フラグ設定します。
/**
* Configures the given JSESSIONID cookie.
*
* @param cookie The JSESSIONID cookie to be configured
*/
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を:あなたフィルタを使用して手動で設定することができます。 set 'secure' flag to JSESSION id cookie
あなたが選んだブラウザの開発ツール(私の場合はSafariのWebinspector )は、そのクッキーが確かに安全専用のクッキーであることを伝えます –