8:Spring Boot Shiro记住密码
1,添加Cookie
2,添加安全管理器中
3,配置记住我,
4 ,在登录页面中加我rememberMe复选框
/**
* 1.配置Cookie对象
* 记住我的cookie:rememberMe
* @return SimpleCookie rememberMeCookie
*/
@Bean
public SimpleCookie rememberMeCookie() {
SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
//simpleCookie.setHttpOnly(true);
//单位(秒)1天
simpleCookie.setMaxAge(60*60*24);
return simpleCookie;
}
/**
* 2.配置cookie管理对象
* @return CookieRememberMeManager
*/
@Bean
public CookieRememberMeManager cookieRememberMeManager() {
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
cookieRememberMeManager.setCookie(rememberMeCookie());
return cookieRememberMeManager;
}
3.
//配置记住我
securityManager.setRememberMeManager(cookieRememberMeManager());
4.
<input type="checkbox" id="rememberMe" name="rememberMe" checked="true" lay-skin="primary" title="记住我"/>