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.
stringgetExpiresTimestamp(): int|null
Get the timestamp from the expiration time
int|nullgetExpiry(): DateTimeDateTimeImmutable|null
Get the current expiry time
DateTimeDateTimeImmutable|nullgetFormattedExpires(): string
Builds the expiration value part of the header string
stringgetId(): string
Get the id for a cookie
Cookies are unique across name, domain, path tuples.
stringgetName(): string
Gets the cookie name
stringgetOptions(): array<string, mixed>
Get cookie options
array<string, mixed>getPath(): string
Get the path attribute.
stringgetSameSite(): string|null
Get the SameSite attribute.
string|nullgetScalarValue(): mixed
Gets the cookie value as scalar.
This will collapse any complex data in the cookie with json_encode()
mixedgetValue(): array|string
Gets the cookie value
array|stringisExpired(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.
boolisHttpOnly(): bool
Check if the cookie is HTTP only
boolisSecure(): bool
Check if the cookie is secure
booltoArray(): array<string, mixed>
Get cookie data as array.
array<string, mixed>toHeaderValue(): string
Returns the cookie as header value
stringwithDomain(string $domain): static
Create a cookie with an updated domain
string $domain Domain to set
staticwithExpired(): 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
staticwithExpiry(DateTimeDateTimeImmutable $dateTime): static
Create a cookie with an updated expiration date
DateTimeDateTimeImmutable $dateTime Date time object
staticwithHttpOnly(bool $httpOnly): static
Create a cookie with HTTP Only updated
bool $httpOnly HTTP Only
staticwithName(string $name): static
Sets the cookie name
string $name Name of the cookie
staticwithNeverExpire(): static
Create a new cookie that will virtually never expire.
staticwithPath(string $path): static
Create a new cookie with an updated path
string $path Sets the path
staticwithSameSite(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.
staticwithSecure(bool $secure): static
Create a cookie with Secure updated
bool $secure Secure attribute value
staticwithValue(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