Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BrowserKitDriver.php

function BrowserKitDriver::getCookie

Overrides CoreDriver::getCookie

File

vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php, line 269

Class

BrowserKitDriver
Symfony BrowserKit driver.

Namespace

Behat\Mink\Driver

Code

public function getCookie(string $name) {
    // Note that the following doesn't work well because
    // Symfony\Component\BrowserKit\CookieJar stores cookies by name,
    // path, AND domain and if you don't fill them all in correctly then
    // you won't get the value that you're expecting.
    //
    // $jar = $this->client->getCookieJar();
    //
    // if (null !== $cookie = $jar->get($name)) {
    //     return $cookie->getValue();
    // }
    $allValues = $this->client
        ->getCookieJar()
        ->allValues($this->getCurrentUrl());
    if (isset($allValues[$name])) {
        return $allValues[$name];
    }
    return null;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal