function UiHelperTrait::drupalUserIsLoggedIn

Same name in other branches
  1. 9 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalUserIsLoggedIn()
  2. 8.9.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalUserIsLoggedIn()
  3. 11.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalUserIsLoggedIn()

Returns whether a given user account is logged in.

Parameters

\Drupal\Core\Session\AccountInterface $account: The user account object to check.

Return value

bool Return TRUE if the user is logged in, FALSE otherwise.

5 calls to UiHelperTrait::drupalUserIsLoggedIn()
DemoUmamiProfileTest::drupalLoginWithPassword in core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php
Logs in a user using the Mink controlled browser using a password.
JsonApiFunctionalTest::testRead in core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php
Tests the GET method.
UiHelperTrait::drupalLogin in core/tests/Drupal/Tests/UiHelperTrait.php
Logs in a user using the Mink controlled browser.
UserHelpersTest::testDrupalUserIsLoggedIn in core/tests/Drupal/FunctionalTests/UserHelpersTest.php
Tests BrowserTestBase::drupalUserIsLoggedIn().
UserLogoutTest::testLogout in core/modules/user/tests/src/Functional/UserLogoutTest.php
Tests user logout functionality.

File

core/tests/Drupal/Tests/UiHelperTrait.php, line 406

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function drupalUserIsLoggedIn(AccountInterface $account) {
    $logged_in = FALSE;
    if (isset($account->sessionId)) {
        $session_handler = \Drupal::service('session_handler.storage');
        $logged_in = (bool) $session_handler->read($account->sessionId);
    }
    return $logged_in;
}

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