function user_logout

7.x user.pages.inc user_logout()
6.x user.pages.inc user_logout()

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

1 call to user_logout()
_menu_site_is_offline in drupal-6.x/includes/menu.inc
Checks whether the site is off-line for maintenance.
1 string reference to 'user_logout'
user_menu in drupal-6.x/modules/user/user.module
Implementation of hook_menu().

File

drupal-6.x/modules/user/user.pages.inc, line 145
User page callback file for the user module.

Code

function user_logout() {
  global $user;

  watchdog('user', 'Session closed for %name.', array('%name' => $user->name));

  // Destroy the current session:
  session_destroy();
  // Only variables can be passed by reference workaround.
  $null = NULL;
  user_module_invoke('logout', $null, $user);

  // Load the anonymous user
  $user = drupal_anonymous_user();

  drupal_goto();
}