Skip to main content

Drupal: programmatically log out the user

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