SessionTestHooks.php

Namespace

Drupal\session_test\Hook

File

core/modules/system/tests/modules/session_test/src/Hook/SessionTestHooks.php

View source
<?php

declare (strict_types=1);
namespace Drupal\session_test\Hook;

use Drupal\user\UserInterface;
use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for session_test.
 */
class SessionTestHooks {
    
    /**
     * Implements hook_user_login().
     */
    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");
    }

}

Classes

Title Deprecated Summary
SessionTestHooks Hook implementations for session_test.

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