Question 2: After Shiro configures redis to manage the session, the problem of regenerating the session every time you re-request

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324779334&siteId=291194637