Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserRequestSubscriber.php

function UserRequestSubscriber::onKernelTerminate

Updates the current user's last access time.

Parameters

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

File

core/modules/user/src/EventSubscriber/UserRequestSubscriber.php, line 53

Class

UserRequestSubscriber
Updates the current user's last access time.

Namespace

Drupal\user\EventSubscriber

Code

public function onKernelTerminate(TerminateEvent $event) {
    if ($this->account
        ->isAuthenticated() && $this->time
        ->getRequestTime() - $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->entityTypeManager
            ->getStorage('user');
        $storage->updateLastAccessTimestamp($this->account, $this->time
            ->getRequestTime());
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal