user_logout

  1. drupal
    1. 4.7
    2. 5 user.module
    3. 6 user.pages.inc
    4. 7 user.pages.inc
Versions
4.7 – 7 user_logout()

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

Code

modules/user.module, line 1021

<?php
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();
}
?>