function Selenium2Driver::setCookie
Overrides CoreDriver::setCookie
File
-
vendor/
lullabot/ mink-selenium2-driver/ src/ Selenium2Driver.php, line 504
Class
- Selenium2Driver
- Selenium2 driver.
Namespace
Behat\Mink\DriverCode
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);
}