| Methods |
public
static
|
fromString(string $cookie, bool $decode = false): static
Creates cookie from raw header string.
Creates cookie from raw header string.
|
#
|
public
static
|
create(
string $name,
string $value = null,
int|string|DateTimeInterface $expire = 0,
?string $path = '/',
string $domain = null,
bool $secure = null,
bool $httpOnly = true,
bool $raw = false,
self::SAMESITE_*|''|null $sameSite = self::SAMESITE_LAX,
): self
|
#
|
public
|
__construct(
string $name,
string|null $value = null,
int|string|DateTimeInterface $expire = 0,
string|null $path = '/',
string|null $domain = null,
bool|null $secure = null,
bool $httpOnly = true,
bool $raw = false,
self::SAMESITE_*|''|null $sameSite = self::SAMESITE_LAX,
)
Parameters
| $name |
The name of the cookie
|
| $value |
The value of the cookie
|
| $expire |
The time the cookie expires
|
| $path |
The path on the server in which the cookie will be available on
|
| $domain |
The domain that the cookie is available to
|
| $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
|
| $httpOnly |
Whether the cookie will be made accessible only through the HTTP protocol
|
| $raw |
Whether the cookie value should be sent with no url encoding
|
| $sameSite |
Whether the cookie will be available for cross-site requests
|
Throws
|
#
|
public
|
withValue(?string $value): static
Creates a cookie copy with a new value.
Creates a cookie copy with a new value.
|
#
|
public
|
withDomain(?string $domain): static
Creates a cookie copy with a new domain that the cookie is available to.
Creates a cookie copy with a new domain that the cookie is available to.
|
#
|
public
|
withExpires(int|string|DateTimeInterface $expire = 0): static
Creates a cookie copy with a new time the cookie expires.
Creates a cookie copy with a new time the cookie expires.
|
#
|
private
static
|
expiresTimestamp(int|string|DateTimeInterface $expire = 0): int
Converts expires formats to a unix timestamp.
Converts expires formats to a unix timestamp.
|
#
|
public
|
withPath(string $path): static
Creates a cookie copy with a new path on the server in which the cookie will be available on.
Creates a cookie copy with a new path on the server in which the cookie will be available on.
|
#
|
public
|
withSecure(bool $secure = true): static
Creates a cookie copy that only be transmitted over a secure HTTPS connection from the client.
Creates a cookie copy that only be transmitted over a secure HTTPS connection from the client.
|
#
|
public
|
withHttpOnly(bool $httpOnly = true): static
Creates a cookie copy that be accessible only through the HTTP protocol.
Creates a cookie copy that be accessible only through the HTTP protocol.
|
#
|
public
|
withRaw(bool $raw = true): static
Creates a cookie copy that uses no url encoding.
Creates a cookie copy that uses no url encoding.
|
#
|
public
|
withSameSite(self::SAMESITE_*|''|null $sameSite): static
Creates a cookie copy with SameSite attribute.
Creates a cookie copy with SameSite attribute.
|
#
|
public
|
__toString(): string
Returns the cookie as a string.
Returns the cookie as a string.
|
#
|
public
|
getName(): string
Gets the name of the cookie.
Gets the name of the cookie.
|
#
|
public
|
getValue(): ?string
Gets the value of the cookie.
Gets the value of the cookie.
|
#
|
public
|
getDomain(): ?string
Gets the domain that the cookie is available to.
Gets the domain that the cookie is available to.
|
#
|
public
|
getExpiresTime(): int
Gets the time the cookie expires.
Gets the time the cookie expires.
|
#
|
public
|
getMaxAge(): int
Gets the max-age attribute.
Gets the max-age attribute.
|
#
|
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.
|
#
|
public
|
isSecure(): bool
Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
|
#
|
public
|
isHttpOnly(): bool
Checks whether the cookie will be made accessible only through the HTTP protocol.
Checks whether the cookie will be made accessible only through the HTTP protocol.
|
#
|
public
|
isCleared(): bool
Whether this cookie is about to be cleared.
Whether this cookie is about to be cleared.
|
#
|
public
|
isRaw(): bool
Checks if the cookie value should be sent with no url encoding.
Checks if the cookie value should be sent with no url encoding.
|
#
|
public
|
getSameSite(): self::SAMESITE_*|null
|
#
|
public
|
setSecureDefault(bool $default): void
Parameters
| $default |
The default value of the "secure" flag when it is set to null
|
|
#
|
| Constants |
public
|
SAMESITE_NONE = 'none'
|
#
|
public
|
SAMESITE_LAX = 'lax'
|
#
|
public
|
SAMESITE_STRICT = 'strict'
|
#
|
private
|
RESERVED_CHARS_LIST = "=,; \t\r\n\v\f"
|
#
|
private
|
RESERVED_CHARS_FROM = ['=', ',', ';', ' ', "\t", "\r", "\n", "\v", "\f"]
|
#
|
private
|
RESERVED_CHARS_TO = ['%3D', '%2C', '%3B', '%20', '%09', '%0D', '%0A', '%0B', '%0C']
|
#
|