function Cookie::__toString
Same name in this branch
- 11.1.x vendor/symfony/http-foundation/Cookie.php \Symfony\Component\HttpFoundation\Cookie::__toString()
Returns the HTTP representation of the Cookie.
File
-
vendor/
symfony/ browser-kit/ Cookie.php, line 89
Class
- Cookie
- Cookie represents an HTTP cookie.
Namespace
Symfony\Component\BrowserKitCode
public function __toString() : string {
$cookie = \sprintf('%s=%s', $this->name, $this->rawValue);
if (null !== $this->expires) {
$dateTime = \DateTimeImmutable::createFromFormat('U', $this->expires, new \DateTimeZone('GMT'));
$cookie .= '; expires=' . str_replace('+0000', '', $dateTime->format(self::DATE_FORMATS[0]));
}
if ('' !== $this->domain) {
$cookie .= '; domain=' . $this->domain;
}
if ($this->path) {
$cookie .= '; path=' . $this->path;
}
if ($this->secure) {
$cookie .= '; secure';
}
if ($this->httponly) {
$cookie .= '; httponly';
}
if (null !== $this->samesite) {
$cookie .= '; samesite=' . $this->samesite;
}
return $cookie;
}