protected function WebTestBase::drupalUserIsLoggedIn

Returns whether a given user account is logged in.

Parameters

\Drupal\user\UserInterface $account: The user account object to check.

2 calls to WebTestBase::drupalUserIsLoggedIn()
UserHelpersTest::testDrupalUserIsLoggedIn in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/UserHelpersTest.php
Tests WebTestBase::drupalUserIsLoggedIn().
WebTestBase::drupalLogin in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Log in a user with the internal browser.

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 661
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalUserIsLoggedIn($account) {
  if (!isset($account->session_id)) {
    return FALSE;
  }

  // @see _drupal_session_read()
  return (bool) db_query("SELECT sid FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(
    ':sid' => $account->session_id,
  ))
    ->fetchField();
}