Java Code Examples for org.apache.shiro.web.session.mgt.DefaultWebSessionManager#setGlobalSessionTimeout()

The following examples show how to use org.apache.shiro.web.session.mgt.DefaultWebSessionManager#setGlobalSessionTimeout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShiroConfig.java    From MeetingFilm with Apache License 2.0 6 votes vote down vote up
/**
 * session管理器(单机环境)
 */
@Bean
@ConditionalOnProperty(prefix = "guns", name = "spring-session-open", havingValue = "false")
public DefaultWebSessionManager defaultWebSessionManager(CacheManager cacheShiroManager, GunsProperties gunsProperties) {
    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
    sessionManager.setCacheManager(cacheShiroManager);
    sessionManager.setSessionValidationInterval(gunsProperties.getSessionValidationInterval() * 1000);
    sessionManager.setGlobalSessionTimeout(gunsProperties.getSessionInvalidateTime() * 1000);
    sessionManager.setDeleteInvalidSessions(true);
    sessionManager.setSessionValidationSchedulerEnabled(true);
    Cookie cookie = new SimpleCookie(ShiroHttpSession.DEFAULT_SESSION_ID_NAME);
    cookie.setName("shiroCookie");
    cookie.setHttpOnly(true);
    sessionManager.setSessionIdCookie(cookie);
    return sessionManager;
}
 
Example 2
Source File: ShiroConfig.java    From WebStack-Guns with MIT License 6 votes vote down vote up
/**
 * session管理器(单机环境)
 */
@Bean
@ConditionalOnProperty(prefix = "guns", name = "spring-session-open", havingValue = "false")
public DefaultWebSessionManager defaultWebSessionManager(CacheManager cacheShiroManager, GunsProperties gunsProperties) {
    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
    sessionManager.setCacheManager(cacheShiroManager);
    sessionManager.setSessionValidationInterval(gunsProperties.getSessionValidationInterval() * 1000);
    sessionManager.setGlobalSessionTimeout(gunsProperties.getSessionInvalidateTime() * 1000);
    sessionManager.setDeleteInvalidSessions(true);
    sessionManager.setSessionValidationSchedulerEnabled(true);
    Cookie cookie = new SimpleCookie(ShiroHttpSession.DEFAULT_SESSION_ID_NAME);
    cookie.setName("shiroCookie");
    cookie.setHttpOnly(true);
    sessionManager.setSessionIdCookie(cookie);
    return sessionManager;
}
 
Example 3
Source File: ShiroConfig.java    From springboot-learn with MIT License 6 votes vote down vote up
/**
 * 会话管理器
 */
@Bean
public DefaultWebSessionManager sessionManager() {
    DefaultWebSessionManager manager = new DefaultWebSessionManager();
    // 加入缓存管理器
    manager.setCacheManager(getEhCacheManager());
    // 删除过期的session
    manager.setDeleteInvalidSessions(true);
    // 设置全局session超时时间
    manager.setGlobalSessionTimeout(30 * 60 * 1000);
    // 是否定时检查session
    manager.setSessionValidationSchedulerEnabled(true);
    // 自定义SessionDao
    manager.setSessionDAO(new EnterpriseCacheSessionDAO());
    return manager;
}
 
Example 4
Source File: ShiroConfig.java    From SpringBootBucket with MIT License 6 votes vote down vote up
@Bean(name = "sessionManager")
public DefaultWebSessionManager defaultWebSessionManager() {
    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
    sessionManager.setGlobalSessionTimeout(18000000);
    // url中是否显示session Id
    sessionManager.setSessionIdUrlRewritingEnabled(false);
    // 删除失效的session
    sessionManager.setDeleteInvalidSessions(true);
    sessionManager.setSessionValidationSchedulerEnabled(true);
    sessionManager.setSessionValidationInterval(18000000);
    sessionManager.setSessionValidationScheduler(getExecutorServiceSessionValidationScheduler());
    //设置SessionIdCookie 导致认证不成功,不从新设置新的cookie,从sessionManager获取sessionIdCookie
    //sessionManager.setSessionIdCookie(simpleIdCookie());
    sessionManager.getSessionIdCookie().setName("session-z-id");
    sessionManager.getSessionIdCookie().setPath("/");
    sessionManager.getSessionIdCookie().setMaxAge(60 * 60 * 24 * 7);
    return sessionManager;
}
 
Example 5
Source File: ShiroConfig.java    From erp-framework with MIT License 5 votes vote down vote up
/**
 * 配置会话管理器,设定会话超时及保存
 * @return
 */
@Bean
public SessionManager sessionManager() {
    DefaultWebSessionManager manager = new DefaultWebSessionManager();
    //设置session过期时间为1小时(单位:毫秒),默认为30分钟
    manager.setGlobalSessionTimeout(60 * 60 * 1000);
    // 是否开启定时调度器进行检测过期session
    manager.setSessionValidationSchedulerEnabled(true);
    manager.setSessionDAO(sessionDao());
    return manager;
}
 
Example 6
Source File: ShiroConfiguration.java    From spring-boot-seed with MIT License 5 votes vote down vote up
/**
 * SessionManager,设置Session超时
 *
 * @return SessionManager
 */
@Bean
public SessionManager sessionManager() {
    DefaultWebSessionManager defaultWebSessionManager = new DefaultWebSessionManager();
    defaultWebSessionManager.setGlobalSessionTimeout(7200000);
    defaultWebSessionManager.setDeleteInvalidSessions(true);
    return defaultWebSessionManager;
}
 
Example 7
Source File: ShiroConfig.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@Bean
public SessionManager webSessionManager(){
    DefaultWebSessionManager manager = new DefaultWebSessionManager();
    //设置session过期时间为1小时(单位:毫秒),默认为30分钟
    manager.setGlobalSessionTimeout(60 * 60 * 1000);
    manager.setSessionValidationSchedulerEnabled(true);
    manager.setSessionDAO(redisSessionDAO());
    return manager;
}
 
Example 8
Source File: ShiroConfig.java    From Spring-Shiro-Spark with Apache License 2.0 5 votes vote down vote up
@Bean(name = "sessionManager")
public DefaultWebSessionManager sessionManager(){
    DefaultWebSessionManager manager = new DefaultWebSessionManager();
    //manager.setCacheManager(cacheManager);// 加入缓存管理器
    manager.setSessionFactory(shiroSessionFactory());//设置sessionFactory
    manager.setSessionDAO(shiroSessionDao());// 设置SessionDao
    manager.setDeleteInvalidSessions(true);// 删除过期的session
    manager.setGlobalSessionTimeout(shiroSessionDao().getExpireTime());// 设置全局session超时时间
    manager.setSessionValidationSchedulerEnabled(true);// 是否定时检查session
    return manager;
}
 
Example 9
Source File: ShiroConfig.java    From server-boilerplate with MIT License 5 votes vote down vote up
@Bean
public SessionManager getSessionManager() {
    DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
    sessionManager.setGlobalSessionTimeout(180000);
    sessionManager.setDeleteInvalidSessions(true);
    return sessionManager;
}