function Cookie::__toString
Same name in this branch
- 11.1.x vendor/symfony/browser-kit/Cookie.php \Symfony\Component\BrowserKit\Cookie::__toString()
Returns the cookie as a string.
File
-
vendor/
symfony/ http-foundation/ Cookie.php, line 253
Class
- Cookie
- Represents a cookie.
Namespace
Symfony\Component\HttpFoundationCode
public function __toString() : string {
if ($this->isRaw()) {
$str = $this->getName();
}
else {
$str = str_replace(self::RESERVED_CHARS_FROM, self::RESERVED_CHARS_TO, $this->getName());
}
$str .= '=';
if ('' === (string) $this->getValue()) {
$str .= 'deleted; expires=' . gmdate('D, d M Y H:i:s T', time() - 31536001) . '; Max-Age=0';
}
else {
$str .= $this->isRaw() ? $this->getValue() : rawurlencode($this->getValue());
if (0 !== $this->getExpiresTime()) {
$str .= '; expires=' . gmdate('D, d M Y H:i:s T', $this->getExpiresTime()) . '; Max-Age=' . $this->getMaxAge();
}
}
if ($this->getPath()) {
$str .= '; path=' . $this->getPath();
}
if ($this->getDomain()) {
$str .= '; domain=' . $this->getDomain();
}
if ($this->isSecure()) {
$str .= '; secure';
}
if ($this->isHttpOnly()) {
$str .= '; httponly';
}
if (null !== $this->getSameSite()) {
$str .= '; samesite=' . $this->getSameSite();
}
if ($this->isPartitioned()) {
$str .= '; partitioned';
}
return $str;
}