function SessionTestHooks::userLogin

Implements hook_user_login().

Attributes

#[Hook('user_login')]

File

core/modules/system/tests/modules/session_test/src/Hook/SessionTestHooks.php, line 18

Class

SessionTestHooks
Hook implementations for session_test.

Namespace

Drupal\session_test\Hook

Code

public function userLogin(UserInterface $account) : void {
  if ($account->getAccountName() == 'session_test_user') {
    // Exit so we can verify that the session was regenerated
    // before hook_user_login() was called.
    exit;
  }
  // Add some data in the session for retrieval testing purpose.
  \Drupal::request()->getSession()
    ->set("session_test_key", "foobar");
}

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