Cookie Interface
string
'D, d-M-Y H:i:s T'
string
'Lax'
string
'None'
string
'Strict'
string[]
[self::SAMESITE_LAX, self::SAMESITE_STRICT, self::SAMESITE_NONE]
getDomain()
Get the domain attribute.
string
getExpiresTimestamp()
Get the timestamp from the expiration time
int|null
The expiry time as an integer.
getExpiry()
Get the current expiry time
\DateTime|\DateTimeImmutable|null
Timestamp of expiry or null
getFormattedExpires()
Builds the expiration value part of the header string
string
getId()
Get the id for a cookie
Cookies are unique across name, domain, path tuples.
string
getName()
Gets the cookie name
string
getOptions()
Get cookie options
array
getPath()
Get the path attribute.
string
getSameSite()
Get the SameSite attribute.
string|null
getScalarValue()
Gets the cookie value as scalar.
This will collapse any complex data in the cookie with json_encode()
mixed
getValue()
Gets the cookie value
string|array
isExpired(mixed $time)
Check if a cookie is expired when compared to $time
Cookies without an expiration date always return false.
\DateTime|\DateTimeImmutable
$time optional The time to test against. Defaults to 'now' in UTC.
bool
isHttpOnly()
Check if the cookie is HTTP only
bool
isSecure()
Check if the cookie is secure
bool
toArray()
Get cookie data as array.
array
With keys name
, value
, expires
etc. options.
toHeaderValue()
Returns the cookie as header value
string
withDomain(string $domain)
Create a cookie with an updated domain
string
$domain Domain to set
static
withExpired()
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(mixed $dateTime)
Create a cookie with an updated expiration date
\DateTime|\DateTimeImmutable
$dateTime Date time object
static
withHttpOnly(bool $httpOnly)
Create a cookie with HTTP Only updated
bool
$httpOnly HTTP Only
static
withName(string $name)
Sets the cookie name
string
$name Name of the cookie
static
withNeverExpire()
Create a new cookie that will virtually never expire.
static
withPath(string $path)
Create a new cookie with an updated path
string
$path Sets the path
static
withSameSite(?string $sameSite)
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)
Create a cookie with Secure updated
bool
$secure Secure attribute value
static
withValue(mixed $value)
Create a cookie with an updated value.
string|array
$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.1/interface-Cake.Http.Cookie.CookieInterface.html