user_logout

Definition

user_logout()
user/user.module, line 1033

Description

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

Code

<?php
function user_logout() {
  global $user;

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

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

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

  drupal_goto();
}
?>