session_test.module

Same filename in other branches
  1. 7.x modules/simpletest/tests/session_test.module
  2. 9 core/modules/system/tests/modules/session_test/session_test.module
  3. 10 core/modules/system/tests/modules/session_test/session_test.module
  4. 11.x core/modules/system/tests/modules/session_test/session_test.module

Test module.

File

core/modules/system/tests/modules/session_test/session_test.module

View source
<?php


/**
 * @file
 * Test module.
 */
use Drupal\user\UserInterface;

/**
 * Implements hook_user_login().
 */
function session_test_user_login(UserInterface $account) {
    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");
}

Functions

Title Deprecated Summary
session_test_user_login Implements hook_user_login().

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