CookieTrait.php in Zircon Profile 8
File
vendor/jcalderonzumba/mink-phantomjs-driver/src/CookieTrait.php
View source
<?php
namespace Zumba\Mink\Driver;
use Zumba\GastonJS\Cookie;
trait CookieTrait {
public function setCookie($name, $value = null) {
if ($value === null) {
$this->browser
->removeCookie($name);
}
if ($value !== null) {
$urlData = parse_url($this
->getCurrentUrl());
$cookie = array(
"name" => $name,
"value" => $value,
"domain" => $urlData["host"],
);
$this->browser
->setCookie($cookie);
}
}
public function getCookie($name) {
$cookies = $this->browser
->cookies();
foreach ($cookies as $cookie) {
if ($cookie instanceof Cookie && strcmp($cookie
->getName(), $name) === 0) {
return $cookie
->getValue();
}
}
return null;
}
}