Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiro: Cannot invalidate HttpSession

I have a Shiro session (id=11111) and a http session (id=22222).

When I try to invalidate the HttpSession, the wrong id is used.

Code:

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

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

Exception:

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

How can I invalidate the HttpSession or rather set the correct id?

like image 1000
sinclair Avatar asked Aug 07 '15 12:08

sinclair


1 Answers

The problem was solved by implementing a HttpSessionBindingListener and create a mapping of Shiro sessions to http sessions.

like image 131
sinclair Avatar answered Oct 23 '22 13:10

sinclair