Shiro:无法使HttpSession无效

sin*_*air 7 session java-ee httpsession shiro

我有一个Shiro会话(id = 11111)和一个http会话(id = 22222).

当我尝试使HttpSession无效时,使用了错误的id.

码:

public void logout() {
      SecurityUtils.getSubject().logout();

// exception is thrown in this line
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
    }

例外:

java.lang.IllegalStateException:
 org.apache.shiro.session.UnknownSessionException:
 There is no session with id [22222]

如何使HttpSession无效或者设置正确的ID?

sin*_*air 1

通过实现 HttpSessionBindingListener 并创建 Shiro 会话到 http 会话的映射解决了该问题。