请问shiro 自定义cookie超时时间怎么弄?

shiro 自定义cookie超时时间怎么弄


一只萌萌小番薯
浏览 2219回答 4
4回答

白衣非少年

默认是HttpOnly的,即浏览器关闭便失效。如果你想要修改Cookie,那么请参考如下配置@Beandef securityManager() {def securityManager = new DefaultWebSecurityManager()securityManager.realm = realm()securityManager.cacheManager = cacheManager()securityManager.sessionManager = sessionManager()securityManager.rememberMeManager = rememberMeManager()return securityManager}def sessionManager() {def sessionManager = new DefaultWebSessionManager()def cookie = new SimpleCookie(ShiroHttpSession.DEFAULT_SESSION_ID_NAME)//cookie.setHttpOnly(true)cookie.maxAge = 24 * 60 * 60sessionManager.sessionIdCookie = cookiereturn sessionManager}def rememberMeManager() {def rememberMeManager = new CookieRememberMeManager()def cookie = new SimpleCookie(CookieRememberMeManager.DEFAULT_REMEMBER_ME_COOKIE_NAME)//cookie.setHttpOnly(true)//cookie.setMaxAge(Cookie.ONE_YEAR)cookie.maxAge = 60 * 60 * 24 * 7rememberMeManager.cookie = cookiereturn rememberMeManager}

www说

ie11下查看cookie:1:IE11=》F12打开开发人员工具2:开发人员工具=》网络F5启用网络流量捕获3:IE11=》输入和访问相关网址4:开发人员工具=》网络=》详细信息=》Cookie如果你只在java后台写的cookie,前端浏览器当然看不到

慕斯709654

因为shiro的登录异常很少,没有设计自定义,不过你可以通过重写异常显示标签来做到:1234567<@shiro.isLoginFailure&nbsp;name="shiroLoginFailure"><!--&nbsp;isLoginFailure&nbsp;是判断shiro登录抛出异常的时候&nbsp;才能进入-->&nbsp;&nbsp;<div&nbsp;class="alert&nbsp;alert-danger"&nbsp;style="background-image:&nbsp;none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<@shiro.loginException&nbsp;name="shiroLoginFailure"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!--&nbsp;loginException&nbsp;是显示具体的异常信息&nbsp;你可以自己照源码写一个标签来代替-->&nbsp;&nbsp;</div></@shiro.isLoginFailure>
打开App,查看更多内容
随时随地看视频慕课网APP