Hello,

Often, I have the need to make sure all users are logged out of a drupal site. (I'm a teacher, and I use drupal. When I teach in a lab, I need to make sure that the second class doesn't load up the site with an active login from a previous student.)

So is there something I can run that will reset all the current sessions? Sorry if that's not the terminology -- I'm not actually sure how drupal tracks login states.

I found that I could get what I wanted by blocking a user, and then unblocking them. But that proved to be too resource intensive (I have no idea why) when I tried to do that on 40 accounts at once.

Any ideas for a simple way to do this?

I also tried flushing all the caches, but that didn't do it.

Thanks in advance.

Comments

Sagar Ramgade’s picture

I think you need to empty your sessions table to make them logout. Take a backup before doing this.

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

theamoeba’s picture

This might help from http://snipplr.com/view.php?codeview&id=43513:

// Programmatically logs out the current user
global $user;
$tmp = NULL;
session_destroy();
user_module_invoke('logout', $tmp, $user);
$user = drupal_anonymous_user();