function UserStorage::updateLastLoginTimestamp

Same name and namespace in other branches
  1. 9 core/modules/user/src/UserStorage.php \Drupal\user\UserStorage::updateLastLoginTimestamp()
  2. 8.9.x core/modules/user/src/UserStorage.php \Drupal\user\UserStorage::updateLastLoginTimestamp()
  3. 11.x core/modules/user/src/UserStorage.php \Drupal\user\UserStorage::updateLastLoginTimestamp()

Update the last login timestamp of the user.

Parameters

\Drupal\user\UserInterface $account: The user account.

Overrides UserStorageInterface::updateLastLoginTimestamp

File

core/modules/user/src/UserStorage.php, line 44

Class

UserStorage
Controller class for users.

Namespace

Drupal\user

Code

public function updateLastLoginTimestamp(UserInterface $account) {
  $this->database
    ->update($this->getDataTable())
    ->fields([
    'login' => $account->getLastLoginTime(),
  ])
    ->condition('uid', $account->id())
    ->execute();
  // Ensure that the entity cache is cleared.
  $this->resetCache([
    $account->id(),
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.