Cookie Interface
string
'D, d-M-Y H:i:s T'
Expires attribute format.
string
'Lax'
SameSite attribute value: Lax
string
'None'
SameSite attribute value: None
string
'Strict'
SameSite attribute value: Strict
array<string>
[self::SAMESITE_LAX, self::SAMESITE_STRICT, self::SAMESITE_NONE]
Valid values for "SameSite" attribute.
Get the domain attribute.
Get the timestamp from the expiration time
Get the current expiry time
Builds the expiration value part of the header string
Get the id for a cookie
Gets the cookie name
Get cookie options
Get the path attribute.
Get the SameSite attribute.
Gets the cookie value as scalar.
Gets the cookie value
Check if a cookie is expired when compared to $time
Check if the cookie is HTTP only
Check if the cookie is secure
Get cookie data as array.
Returns the cookie as header value
Create a cookie with an updated domain
Create a new cookie that will expire/delete the cookie from the browser.
Create a cookie with an updated expiration date
Create a cookie with HTTP Only updated
Sets the cookie name
Create a new cookie that will virtually never expire.
Create a new cookie with an updated path
Create a cookie with an updated SameSite option.
Create a cookie with Secure updated
Create a cookie with an updated value.
getDomain(): string
Get the domain attribute.
string
getExpiresTimestamp(): int|null
Get the timestamp from the expiration time
int|null
getExpiry(): DateTimeDateTimeImmutable|null
Get the current expiry time
DateTimeDateTimeImmutable|null
getFormattedExpires(): string
Builds the expiration value part of the header string
string
getId(): string
Get the id for a cookie
Cookies are unique across name, domain, path tuples.
string
getName(): string
Gets the cookie name
string
getOptions(): array<string, mixed>
Get cookie options
array<string, mixed>
getPath(): string
Get the path attribute.
string
getSameSite(): string|null
Get the SameSite attribute.
string|null
getScalarValue(): mixed
Gets the cookie value as scalar.
This will collapse any complex data in the cookie with json_encode()
mixed
getValue(): array|string
Gets the cookie value
array|string
isExpired(DateTimeDateTimeImmutable $time = null): bool
Check if a cookie is expired when compared to $time
Cookies without an expiration date always return false.
DateTimeDateTimeImmutable
$time optional The time to test against. Defaults to 'now' in UTC.
bool
isHttpOnly(): bool
Check if the cookie is HTTP only
bool
isSecure(): bool
Check if the cookie is secure
bool
toArray(): array<string, mixed>
Get cookie data as array.
array<string, mixed>
toHeaderValue(): string
Returns the cookie as header value
string
withDomain(string $domain): static
Create a cookie with an updated domain
string
$domain Domain to set
static
withExpired(): static
Create a new cookie that will expire/delete the cookie from the browser.
This is done by setting the expiration time to 1 year ago
static
withExpiry(DateTimeDateTimeImmutable $dateTime): static
Create a cookie with an updated expiration date
DateTimeDateTimeImmutable
$dateTime Date time object
static
withHttpOnly(bool $httpOnly): static
Create a cookie with HTTP Only updated
bool
$httpOnly HTTP Only
static
withName(string $name): static
Sets the cookie name
string
$name Name of the cookie
static
withNeverExpire(): static
Create a new cookie that will virtually never expire.
static
withPath(string $path): static
Create a new cookie with an updated path
string
$path Sets the path
static
withSameSite(string|null $sameSite): static
Create a cookie with an updated SameSite option.
string|null
$sameSite Value for to set for Samesite option. One of CookieInterface::SAMESITE_* constants.
static
withSecure(bool $secure): static
Create a cookie with Secure updated
bool
$secure Secure attribute value
static
withValue(array|string $value): static
Create a cookie with an updated value.
array|string
$value Value of the cookie to set
static
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/interface-Cake.Http.Cookie.CookieInterface.html