Jump to content

Could I kill all users logged in sessions ?


adrianmak
 Share

Recommended Posts

I put a site settings toggle to turn on/off for front-end user login

if it is on, the login form will not show and with a message something like "Site under maintenance. User login is temporary closed"

I found that is a user is already login and visit those restricted area (required user log-in), and I turn off user login,

those logged in users are still able to visit the restricted area.

How (possible?) do I kill all logged in users' session ?

Link to comment
Share on other sites

session->getAll() does return all session variables, but not sessions. Forcefully logging users out can be done by removing their session files / db entries or by implementing a bit of code into the processwire bootstrap, which checks if a user should be logged out forcefully and redirect right afterwards.

  • Like 2
Link to comment
Share on other sites

You could maybe hook into PageRender::renderPage ?

Take a look at the ForcePasswordChange module: https://github.com/adrianbj/PasswordForceChange/blob/master/PasswordForceChange.module#L57 and the method that is called: https://github.com/adrianbj/PasswordForceChange/blob/master/PasswordForceChange.module#L87

Taking that approach you can prevent them from viewing the restricted pages even if they are logged in. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...