Methods |
public
|
__construct(
string $name,
string $value = '',
array{prefix?: string, max-age?: int<0, max>, expires?: (DateTimeInterface|int<0, max>|string), path?: string, domain?: string, secure?: bool, httponly?: bool, samesite?: (null|string), raw?: bool, partitioned?: bool} $options = [],
null|ClockInterface $clock = null,
)
Parameters
$name |
The name of the cookie
|
$value |
The value of the cookie
|
$options |
An associative array of options for the cookie.
prefix : A prefix to be added to the cookie name.
max-age : The maximum age of the cookie in seconds.
expires : The expiration time of the cookie (in seconds, a DateTimeInterface object, or string).
path : The path on the server in which the cookie will be available on.
domain : The domain that the cookie is available to.
secure : Indicates whether the cookie should only be transmitted over a secure HTTPS connection.
httponly : Indicates whether the cookie is accessible only through the HTTP protocol.
samesite : The SameSite attribute of the cookie (e.g., 'Strict', 'Lax', 'None') or null for default.
raw : Indicates whether the cookie value should be sent as-is without URL encoding.
partitioned : Indicates whether the cookie is tied to a top-level site in a cross-site context.
|
$clock |
The clock instance to use for time calculations. Defaults to the system clock.
|
|
#
|
public
|
__toString(): string
|
#
|
public
static
|
fromHeader(string $header, bool $raw = false): self
Converts a Set-Cookie header string to a CookieInterface object.
Converts a Set-Cookie header string to a CookieInterface object.
Parameters
$header |
The Set-Cookie header string
|
$raw |
Whether the cookie value should be sent without URL encoding
|
Implements
|
#
|
public
|
getPrefix(): string
Gets the prefix of the cookie.
Gets the prefix of the cookie.
Implements
|
#
|
public
|
getName(): string
Gets the name of the cookie without the prefix.
Gets the name of the cookie without the prefix.
Implements
|
#
|
public
|
getPrefixedName(): string
Gets the name of the cookie with the prefix.
Gets the name of the cookie with the prefix.
Implements
|
#
|
public
|
getValue(): string
Gets the value of the cookie.
Gets the value of the cookie.
Implements
|
#
|
public
|
getPath(): string
Gets the path on the server in which the cookie will be available on.
Gets the path on the server in which the cookie will be available on.
Implements
|
#
|
public
|
getDomain(): string
Gets the (sub)domain that the cookie is available to.
Gets the (sub)domain that the cookie is available to.
Implements
|
#
|
public
|
getMaxAge(): int
Gets the Max-Age attribute of the cookie.
Gets the Max-Age attribute of the cookie.
Implements
|
#
|
public
|
getExpiresTimestamp(): int
Gets the time when the cookie expires.
Gets the time when the cookie expires.
Implements
|
#
|
public
|
isExpired(): bool
Indicates if the cookie has expired.
Indicates if the cookie has expired.
Implements
|
#
|
public
|
isSecure(): bool
Indicates if the cookie should only be transmitted over a secure HTTPS connection from the client.
Indicates if the cookie should only be transmitted over a secure HTTPS connection from the client.
Implements
|
#
|
public
|
isHttpOnly(): bool
Indicates if the cookie will be accessible only through the HTTP protocol.
Indicates if the cookie will be accessible only through the HTTP protocol.
Implements
|
#
|
public
|
isRaw(): bool
Indicates if the cookie value should be sent without URL encoding.
Indicates if the cookie value should be sent without URL encoding.
Implements
|
#
|
public
|
isPartitioned(): bool
Indicates if the cookie should be tied to the top-level site in a cross-site context.
Indicates if the cookie should be tied to the top-level site in a cross-site context.
Implements
|
#
|
public
|
getSameSite(): string
Gets the SameSite attribute of the cookie.
Gets the SameSite attribute of the cookie.
Implements
|
#
|
public
|
getOptions(): array
Gets the cookie options that are passable to the setcookie() function.
Gets the cookie options that are passable to the setcookie() function.
Implements
|
#
|
public
|
withPrefix(string $prefix): self
Creates a cookie object with the new prefix.
Creates a cookie object with the new prefix.
Implements
|
#
|
public
|
withName(string $name): self
Creates a cookie object with the new name.
Creates a cookie object with the new name.
Implements
|
#
|
public
|
withValue(string $value): self
Creates a cookie object with the new value.
Creates a cookie object with the new value.
Implements
|
#
|
public
|
withPath(string $path): self
Creates a cookie object with the new Path attribute.
Creates a cookie object with the new Path attribute.
Implements
|
#
|
public
|
withDomain(string $domain): self
Creates a cookie object with the new Domain attribute.
Creates a cookie object with the new Domain attribute.
Implements
|
#
|
public
|
withMaxAge(int $maxAge): self
Creates a cookie object with the new Max-Age attribute.
Creates a cookie object with the new Max-Age attribute.
Implements
|
#
|
public
|
withExpiresTime(DateTimeInterface|int|string $expires): self
Creates a cookie object with the new Expires attribute.
Creates a cookie object with the new Expires attribute.
Implements
|
#
|
public
|
withSecure(bool $secure): self
Creates a cookie object with the new Secure attribute.
Creates a cookie object with the new Secure attribute.
Implements
|
#
|
public
|
withHttpOnly(bool $httpOnly): self
Creates a cookie object with the new HttpOnly attribute.
Creates a cookie object with the new HttpOnly attribute.
Implements
|
#
|
public
|
withSameSite(?string $sameSite): self
Creates a cookie object with the new SameSite attribute.
Creates a cookie object with the new SameSite attribute.
Implements
|
#
|
public
|
withRaw(bool $raw): self
Creates a cookie object that whether the cookie value should be sent without URL encoding.
Creates a cookie object that whether the cookie value should be sent without URL encoding.
Implements
|
#
|
public
|
withPartitioned(bool $partitioned): self
Creates a cookie object that whether the cookie should be tied to the top-level site in a cross-site context.
Creates a cookie object that whether the cookie should be tied to the top-level site in a cross-site context.
Implements
|
#
|