1 user.module user_login_finalize(&$edit = array())

Finalize the login process. Must be called when logging in a user.

The function records a watchdog message about the new session, saves the login timestamp, calls hook_user_login(), and generates a new session.


array $edit: The array of form values submitted by the user.

See also



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


function user_login_finalize(&$edit = array()) {
  global $user;
  watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
  // Update the user table timestamp noting user has logged in.
  // This is also used to invalidate one-time login links.
  $user->login = REQUEST_TIME;
    ->fields(array('login' => $user->login))
    ->condition('uid', $user->uid)

  // Regenerate the session ID to prevent against session fixation attacks.
  // This is called before hook_user in case one of those functions fails
  // or incorrectly does a redirect which would leave the old session in place.

  // If entity caching is enabled, clear the cache entry for the user.
  $entity_info = entity_get_info('user');
  if (isset($entity_info['entity cache']) && $entity_info['entity cache']) {

  user_module_invoke('login', $edit, $user);