下面列出了org.eclipse.jetty.server.session.SessionHandler#setMaxInactiveInterval ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public SessionHandler build() {
SessionHandler sessionHandler = new SessionHandler() {
{
// no setter available for maxCookieAge
_maxCookieAge = (int) cookieMaxAge.toSeconds();
}
};
SessionCache sessionCache = new DefaultSessionCache(sessionHandler);
sessionHandler.setSessionCache(sessionCache);
FileSessionDataStore dataStore = new FileSessionDataStore();
sessionCache.setSessionDataStore(dataStore);
sessionHandler.setHttpOnly(true);
sessionHandler.setSessionTrackingModes(ImmutableSet.of(SessionTrackingMode.COOKIE));
sessionHandler.setMaxInactiveInterval((int) maxInactiveInterval.toSeconds());
sessionHandler.setRefreshCookieAge((int) cookieRefreshAge.toSeconds());
dataStore.setDeleteUnrestorableFiles(true);
dataStore.setStoreDir(new File(path));
dataStore.setSavePeriodSec((int) savePeriod.toSeconds());
return sessionHandler;
}
@Override
public void setSessionConfig() {
SessionHandler sessionHandler = webAppContext.getSessionHandler();
SessionCookieConfig sessionCookieConfig = sessionHandler.getSessionCookieConfig();
sessionCookieConfig.setHttpOnly(true);
sessionCookieConfig.setSecure(systemEnvironment.isSessionCookieSecure());
sessionCookieConfig.setMaxAge(systemEnvironment.sessionCookieMaxAgeInSeconds());
sessionHandler.setMaxInactiveInterval(systemEnvironment.sessionTimeoutInSeconds());
}