function 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.
4 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().
 
File
- 
              core/
tests/ Drupal/ Tests/ UiHelperTrait.php, line 453  
Class
- UiHelperTrait
 - Provides UI helper methods.
 
Namespace
Drupal\TestsCode
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.