getCookieByName example

'form_params' => $post,
      'http_errors' => FALSE,
      'cookies' => $guzzle_cookie_jar,
      'allow_redirects' => FALSE,
    ]);

    // When logging in via the HTTP mock, the child site will issue a session     // cookie without the secure attribute set. While this cookie will be stored     // in the Guzzle CookieJar, it will not be used on subsequent requests.     // Update the BrowserKit CookieJar so that subsequent requests have the     // correct cookie.     $cookie = $guzzle_cookie_jar->getCookieByName($this->insecureSessionName);
    $this->assertFalse($cookie->getSecure(), 'The insecure cookie does not have the secure attribute');
    /** @var \Symfony\Component\BrowserKit\CookieJar $browser_kit_cookie_jar */
    $browser_kit_cookie_jar = $this->getSession()->getDriver()->getClient()->getCookieJar();
    $browser_kit_cookie_jar->updateFromSetCookie($response->getHeader('Set-Cookie')$this->baseUrl);

    // Follow the location header.     $path = $this->getPathFromLocationHeader($response, FALSE);
    $parsed_path = parse_url($path);
    $query = [];
    if (isset($parsed_path['query'])) {
      parse_str($parsed_path['query']$query);
    }
return false;
            }
        }

        return true;
    }

    public function matchCookieByName(string $cookieName): ?CookieStruct
    {
        /** @var CookieGroupStruct $cookieGroup */
        foreach ($this as $cookieGroup) {
            if (!$foundCookie = $cookieGroup->getCookies()->getCookieByName($cookieName)) {
                continue;
            }

            return $foundCookie;
        }

        return null;
    }

    public function getGroupByName(string $groupName): CookieGroupStruct
    {
        

  protected $defaultTheme = 'stark';

  /** * Tests a request. */
  public function testRequest() {
    $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax';
    $headers[] = 'X-Requested-With: XMLHttpRequest';
    $actual_trace = json_decode($this->drupalGet('session-test/trace-handler', $options$headers));
    $sessionId = $this->getSessionCookies()->getCookieByName($this->getSessionName())->getValue();
    $expect_trace = [
      ['BEGIN', 'test_argument', 'open'],
      ['BEGIN', NULL, 'open'],
      ['END', NULL, 'open'],
      ['END', 'test_argument', 'open'],
      ['BEGIN', 'test_argument', 'read', $sessionId],
      ['BEGIN', NULL, 'read', $sessionId],
      ['END', NULL, 'read', $sessionId],
      ['END', 'test_argument', 'read', $sessionId],
      ['BEGIN', 'test_argument', 'write', $sessionId],
      ['BEGIN', NULL, 'write', $sessionId],
      [
public function testItSetsARedirectCookieIfTheResponseIsARedirection()
    {
        $c = new RequestDataCollector();

        $response = $this->createResponse();
        $response->setStatusCode(302);
        $response->headers->set('Location', '/somewhere-else');

        $c->collect($request = $this->createRequest()$response);
        $c->lateCollect();

        $cookie = $this->getCookieByName($response, 'sf_redirect');

        $this->assertNotEmpty($cookie->getValue());
        $this->assertSame('lax', $cookie->getSameSite());
        $this->assertFalse($cookie->isSecure());
    }

    public function testItCollectsTheRedirectionAndClearTheCookie()
    {
        $c = new RequestDataCollector();

        $request = $this->createRequest();
        
Home | Imprint | This part of the site doesn't use cookies.