function BrowserTestBase::getSessionCookies

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getSessionCookies()
  2. 10 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getSessionCookies()
  3. 9 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getSessionCookies()
  4. 8.9.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getSessionCookies()

Get session cookies from current session.

Return value

\GuzzleHttp\Cookie\CookieJar A cookie jar with the current session.

6 calls to BrowserTestBase::getSessionCookies()
ContextualDynamicContextTest::renderContextualLinks in core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
Get server-rendered contextual links for the given contextual link ids.
ContextualDynamicContextTest::testTokenProtection in core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
Tests the contextual placeholder content is protected by a token.
CsrfRequestHeaderTest::testRouteAccess in core/modules/system/tests/src/Functional/CsrfRequestHeaderTest.php
Tests access to routes protected by CSRF request header requirements.
EditorSecurityTest::testSwitchingSecurity in core/modules/editor/tests/src/Functional/EditorSecurityTest.php
Tests administrator security: is the user safe when switching text formats?
SaveUploadTest::testInvalidUtf8FilenameUpload in core/modules/file/tests/src/Functional/SaveUploadTest.php
Tests that filenames containing invalid UTF-8 are rejected.

... See full list

File

core/tests/Drupal/Tests/BrowserTestBase.php, line 457

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\Tests

Code

protected function getSessionCookies() {
  $domain = parse_url($this->getUrl(), PHP_URL_HOST);
  $session_name = $this->getSessionName();
  $session_id = $this->getSession()
    ->getCookie($session_name);
  $cookies = [];
  if ($session_id !== NULL) {
    $cookies[$session_name] = $session_id;
  }
  return CookieJar::fromArray($cookies, $domain);
}

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