private Duration idleSavePeriod = Duration.hours(2);
private Duration savePeriod = Duration.minutes(5);
private Duration scavengePeriod = Duration.minutes(5);
public SessionManager build() throws IOException {
HashSessionManager manager = new HashSessionManager();
manager.setSessionTrackingModes(ImmutableSet.of(SessionTrackingMode.COOKIE));
manager.setHttpOnly(true);
manager.getSessionCookieConfig().setHttpOnly(true);
manager.setDeleteUnrestorableSessions(true);
manager.setStoreDirectory(new File(getPath()));
manager.getSessionCookieConfig().setMaxAge((int) cookieMaxAge.toSeconds());
manager.setRefreshCookieAge((int) cookieRefreshAge.toSeconds());
manager.setMaxInactiveInterval((int) maxInactiveInterval.toSeconds());
manager.setIdleSavePeriod((int) idleSavePeriod.toSeconds());
manager.setSavePeriod((int) savePeriod.toSeconds());
manager.setScavengePeriod((int) scavengePeriod.toSeconds());
return manager;
}