You are here

function user_logout in Drupal 4

Same name and namespace in other branches
  1. 8 core/modules/user/user.module \user_logout()
  2. 5 modules/user/user.module \user_logout()
  3. 6 modules/user/user.pages.inc \user_logout()
  4. 7 modules/user/user.pages.inc \user_logout()
  5. 9 core/modules/user/user.module \user_logout()

Menu callback; logs the current user out, and redirects to the home page.

1 string reference to 'user_logout'
user_menu in modules/user.module
Implementation of hook_menu().

File

modules/user.module, line 1020
Enables the user registration and login system.

Code

function user_logout() {
  global $user;
  watchdog('user', t('Session closed for %name.', array(
    '%name' => theme('placeholder', $user->name),
  )));

  // Destroy the current session:
  session_destroy();
  module_invoke_all('user', 'logout', NULL, $user);

  // We have to use $GLOBALS to unset a global variable:
  $user = user_load(array(
    'uid' => 0,
  ));
  drupal_goto();
}