You are here

public function BrowserKitDriver::getCookie in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php \Behat\Mink\Driver\BrowserKitDriver::getCookie()

Returns cookie by name.

Parameters

string $name:

Return value

string|null

Throws

UnsupportedDriverActionException When operation not supported by the driver

DriverException When the operation cannot be done

Overrides CoreDriver::getCookie

File

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

Class

BrowserKitDriver
Symfony2 BrowserKit driver.

Namespace

Behat\Mink\Driver

Code

public function getCookie($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;
}