You are here

public function UserRequestSubscriber::onKernelTerminate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/EventSubscriber/UserRequestSubscriber.php \Drupal\user\EventSubscriber\UserRequestSubscriber::onKernelTerminate()

Updates the current user's last access time.

Parameters

\Symfony\Component\HttpKernel\Event\PostResponseEvent $event: The event to process.

File

core/modules/user/src/EventSubscriber/UserRequestSubscriber.php, line 55
Contains \Drupal\user\EventSubscriber\UserRequestSubscriber.

Class

UserRequestSubscriber
Updates the current user's last access time.

Namespace

Drupal\user\EventSubscriber

Code

public function onKernelTerminate(PostResponseEvent $event) {
  if ($this->account
    ->isAuthenticated() && REQUEST_TIME - $this->account
    ->getLastAccessedTime() > Settings::get('session_write_interval', 180)) {

    // Do that no more than once per 180 seconds.

    /** @var \Drupal\user\UserStorageInterface $storage */
    $storage = $this->entityManager
      ->getStorage('user');
    $storage
      ->updateLastAccessTimestamp($this->account, REQUEST_TIME);
  }
}