function Cookie::withSameSite
Creates a cookie copy with SameSite attribute.
Parameters
self::SAMESITE_*|''|null $sameSite:
File
-
vendor/
symfony/ http-foundation/ Cookie.php, line 221
Class
- Cookie
- Represents a cookie.
Namespace
Symfony\Component\HttpFoundationCode
public function withSameSite(?string $sameSite) : static {
if ('' === $sameSite) {
$sameSite = null;
}
elseif (null !== $sameSite) {
$sameSite = strtolower($sameSite);
}
if (!\in_array($sameSite, [
self::SAMESITE_LAX,
self::SAMESITE_STRICT,
self::SAMESITE_NONE,
null,
], true)) {
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
}
$cookie = clone $this;
$cookie->sameSite = $sameSite;
return $cookie;
}