user_logout

Definition

user_logout()
modules/user.module, line 1020

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

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.