function Cookie::__construct
Same name in this branch
- 11.1.x vendor/symfony/browser-kit/Cookie.php \Symfony\Component\BrowserKit\Cookie::__construct()
- 11.1.x core/modules/user/src/Authentication/Provider/Cookie.php \Drupal\user\Authentication\Provider\Cookie::__construct()
Parameters
string $name The name of the cookie:
string|null $value The value of the cookie:
int|string|\DateTimeInterface $expire The time the cookie expires:
string|null $path The path on the server in which the cookie will be available on:
string|null $domain The domain that the cookie is available to:
bool|null $secure Whether the client should send back the cookie only over HTTPS or null to auto-enable this when the request is already using HTTPS:
bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol:
bool $raw Whether the cookie value should be sent with no url encoding:
self::SAMESITE_*|''|null $sameSite Whether the cookie will be available for cross-site requests:
Throws
\InvalidArgumentException
File
-
vendor/
symfony/ http-foundation/ Cookie.php, line 90
Class
- Cookie
- Represents a cookie.
Namespace
Symfony\Component\HttpFoundationCode
public function __construct(string $name, ?string $value = null, int|string|\DateTimeInterface $expire = 0, ?string $path = '/', ?string $domain = null, ?bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = self::SAMESITE_LAX, bool $partitioned = false) {
// from PHP source code
if ($raw && false !== strpbrk($name, self::RESERVED_CHARS_LIST)) {
throw new \InvalidArgumentException(\sprintf('The cookie name "%s" contains invalid characters.', $name));
}
if (!$name) {
throw new \InvalidArgumentException('The cookie name cannot be empty.');
}
$this->expire = self::expiresTimestamp($expire);
$this->path = $path ?: '/';
$this->sameSite = $this->withSameSite($sameSite)->sameSite;
}