Our Drupal 7.5 website is having an issue where users click logout but they are sent to the front page still logged in. I believe it's related to a bakery module, however, the question I am asking here is this: how do I force logout for specific users (not all users) via command line?

I tried:

drush uinf <username>

(To get user ID)

drush sql-query "DELETE FROM sessions WHERE uid = <uid>;"

The end result was a sql deadlock that crashed the site momentarily, and when it came back up, the user was still logged in. Should the sql command have worked? If so, then I may need to troubleshoot other issues.

Update: I disabled the bakery module and the problem went away, so the command was correct, but something about the module was wrong. I don't know why.


2 Answers 2


I disabled the Bakery module and am now able to clear the flood tables using the command without getting the deadlock.


One solution could be to install the masquerade, masquerade as that user and in the url: user/logout. It also works and like this: user/login

Other options:

Drush login, Drush logout

and this related post: How to logout all active users? suggestes to empty the sessions table, well while you only want for one selected user, do a join if needed and specify the $uid

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.