您好,环境是这样的
模块admin
http://localhost:8081/admin/login 得到sessionid是
22:05:38 DEBUG net.sf.ehcache.Cache - Cache: admin-SessionCache store hit for 1a22b751-0542-4e74-a8e7-59942692f6ae
模块user
http://localhost:8082/user/login 得到sessionid是
22:07:01 DEBUG net.sf.ehcache.Cache - Cache: user-SessionCache store hit for 38c7d0d9-b13c-42f5-9e36-304838838c02
当admin登陆成功后,去刷新user(并不登陆,就在登陆页面刷新)
这个时候admin就会自动退出登陆,且提示
22:13:37 DEBUG o.a.shiro.web.servlet.SimpleCookie - Found 'sid' cookie value [38c7d0d9-b13c-42f5-9e36-304838838c02]
22:13:37 DEBUG net.sf.ehcache.Cache - mx-master-SessionCache cache - Miss
22:13:37 DEBUG o.a.shiro.mgt.DefaultSecurityManager - Resolved SubjectContext context session is invalid. Ignoring and creating an anonymous (session-less) Subject instance.
org.apache.shiro.session.UnknownSessionException: There is no session with id [38c7d0d9-b13c-42f5-9e36-304838838c02]
user也会报错,提示
22:13:37 DEBUG o.a.shiro.web.servlet.SimpleCookie - Found 'sid' cookie value [1a22b751-0542-4e74-a8e7-59942692f6ae]
22:13:37 DEBUG net.sf.ehcache.Cache - mx-master-SessionCache cache - Miss
22:13:37 DEBUG o.a.shiro.mgt.DefaultSecurityManager - Resolved SubjectContext context session is invalid. Ignoring and creating an anonymous (session-less) Subject instance.
org.apache.shiro.session.UnknownSessionException: There is no session with id [1a22b751-0542-4e74-a8e7-59942692f6ae]
两个id是串联起来了一样,求解决办法,但是如果这2个模块,在不同浏览器下,就不会出现这个问题,难道是session的name一样导致的吗?
admin覆盖user,或者user覆盖admin
解决办法:
2个web模块,分别设置不同的sessionIdCookie的name即可
感谢3楼的哥们(geshiwuyu)