When using shiro, the redis cache session is configured, but each request, including refreshing the page, will re-save a session in redis. Later, it was found that it was the domian problem of the cookie setting, resulting in a different domain name for each request, and the background will automatically regenerate the session.
@Bean(name="sessionIdCookie")
public SimpleCookie sessionIdCookie(){
//cookie名
SimpleCookie sessionIdCookie = new SimpleCookie(Constent.SHIRO_SESSION_ID_COOKIE_NAME);
//Effective time
sessionIdCookie.setHttpOnly(true);
sessionIdCookie.setMaxAge(Constent.SHIRO_SESSION_ID_COOKIE_MAXAGE);
// sessionIdCookie.setDomain("/");
return sessionIdCookie;
}
Just comment out the red part.
Reference: https://blog.csdn.net/zsg88/article/details/73838461