When I put site in maintenance mode and after turn site back all users sessions are not active (is need to log in account), but I put session to work 2 month and it work.

How to prevent users logout when put site in maintenance?

  • Did the database change during the maintenance mode? Did you do any updates?
    – prkos
    Commented Jun 29, 2018 at 10:01
  • No, I can use something other to stop access for users to site for some time, but also when make updates the site also is in maintenance. And It also lost will drop all sessions.
    – Michael
    Commented Jun 29, 2018 at 10:22

1 Answer 1


This is intended behavior, if user does not have "access site in maintenance mode" permission, then user is logged out.

For Drupal 7 take look on user_menu_site_status_alter

For Drupal 8 take look on Drupal\user\EventSubscriber\MaintenanceModeSubscriber

  • The question was about losing sessions after the Maintenance mode is turned off, not during it.
    – prkos
    Commented Jun 29, 2018 at 16:31
  • Yes, this is the reason why the session is destroyed - the logged-in user visits the website which is in maintenance mode. The user who visits the website after the maintenance mode is turned off will not be logged out.
    – quex
    Commented Jun 29, 2018 at 18:26
  • Thanks for linked to the code here. This is shocking behavior, does anyone know if there were technical reasons behind doing this? Users lose all content they were working on if they hit "submit" or refresh the form they were working on. I am looking for some discussions around this to understand the "why" a bit better. Commented May 10, 2019 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.