我正在構建一個基於嵌入式Tomcat-7.0.55,Spring-Boot-1.1.6,Spring-webmvc/core-4.0.7和Spring-Security - 3.2.5。Tomcat Spring Security - 設置會話cookie過期時間
我的配置是這樣的:
@Configuration
public class ServletCtxConfig {
@Bean
@Profile({ Profiles.PRODUCTION, Profiles.QA, Profiles.DEV })
EmbeddedServletContainerFactory servletContainerFactory() {
TomcatEmbeddedServletContainerFactory retVal = new TomcatEmbeddedServletContainerFactory();
retVal.setContextPath("contextPath");
retVal.setTomcatContextCustomizers(Arrays.asList(contextCustomizer()));
retVal.setPort(111);
Connector httpConnector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
httpConnector.setPort(123);
httpConnector.setRedirectPort(456);
retVal.addAdditionalTomcatConnectors(httpConnector);
return retVal;
}
@Bean
CustomCustomizer contextCustomizer() {
return new CustomCustomizer();
}
}
class CustomCustomizer implements TomcatContextCustomizer {
@Value("${session.timeout:10080}")
Integer sessionTimeOut;
@Override
public void customize(Context context) {
context.setSessionCookieName("comilion-fw");
context.setSessionTimeout(sessionTimeOut);
context.setUseHttpOnly(false);
}
}
我能夠設置會話到期時間,但不會反映在cookie過期時間在瀏覽器上。 有人可以指導我如何設置cookie過期時間嗎?
請您向我們展示您的會話管理配置,以便我們確定其中是否有錯誤? – Aeseir 2014-10-03 03:17:45
將我的配置添加到問題 – Modi 2014-10-03 03:35:43