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

Breadcrumb

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

function Selenium2Driver::setCookie

Overrides CoreDriver::setCookie

File

vendor/lullabot/mink-selenium2-driver/src/Selenium2Driver.php, line 504

Class

Selenium2Driver
Selenium2 driver.

Namespace

Behat\Mink\Driver

Code

public function setCookie(string $name, ?string $value = null) {
    if (null === $value) {
        $this->getWebDriverSession()
            ->deleteCookie($name);
        return;
    }
    // PHP 7.4 changed the way it encodes cookies to better respect the spec.
    // This assumes that the server and the Mink client run on the same version (or
    // at least the same side of the behavior change), so that the server and Mink
    // consider the same value.
    if (\PHP_VERSION_ID >= 70400) {
        $encodedValue = rawurlencode($value);
    }
    else {
        $encodedValue = urlencode($value);
    }
    $cookieArray = array(
        'name' => $name,
        'value' => $encodedValue,
        'secure' => false,
    );
    $this->getWebDriverSession()
        ->setCookie($cookieArray);
}

API Navigation

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