Reputation: 736
In my page I have administrative panel for managing users.
Assume I delete or block any user and this user is already logged into my webpage.
How can I destroy his/her session?
Users log in through j_security_check
(HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest().login(getUsername(), getPassword());
Using:
Upvotes: 1
Views: 1903
Reputation: 19027
You can make use of sesssionObject.invalidate()
method to do so as follows.
HttpSession session=
(HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
session.invalidate();
The invalidate()
method on a session object will destroy the current session which is going on.
Upvotes: 0
Reputation: 691715
You could put some "invalidated" flag in a application-level map, or in the database, and have a servlet filter check at each request that the current user's "invalidated" flag is not set.
Upvotes: 2