Interface CookieInterface
Cookie Interface
Direct Implementers
Constants summary
-
string'D, d-M-Y H:i:s T'
Method Summary
- getDomain() publicGet the domain attribute.
- getExpiresTimestamp() publicGet the timestamp from the expiration time
- getExpiry() publicGet the current expiry time
- getFormattedExpires() publicBuilds the expiration value part of the header string
- getId() publicGet the id for a cookie
- getName() publicGets the cookie name
- getPath() publicGet the path attribute.
- getValue() publicGets the cookie value
- isExpired() publicCheck if a cookie is expired when compared to $time
- isHttpOnly() publicCheck if the cookie is HTTP only
- isSecure() publicCheck if the cookie is secure
- toHeaderValue() publicReturns the cookie as header value
- withDomain() publicCreate a cookie with an updated domain
- withExpired() publicCreate a new cookie that will expire/delete the cookie from the browser.
- withExpiry() publicCreate a cookie with an updated expiration date
- withHttpOnly() publicCreate a cookie with HTTP Only updated
- withName() publicSets the cookie name
- withNeverExpire() publicCreate a new cookie that will virtually never expire.
- withPath() publicCreate a new cookie with an updated path
- withSecure() publicCreate a cookie with Secure updated
- withValue() publicCreate a cookie with an updated value.
Method Detail
getExpiresTimestamp()source public
getExpiresTimestamp( )
Get the timestamp from the expiration time
Timestamps are strings as large timestamps can overflow MAX_INT in 32bit systems.
Returns
string|nullThe expiry time as a string timestamp.
getExpiry()source public
getExpiry( )
Get the current expiry time
Returns
DateTime|DateTimeImmutable|nullTimestamp of expiry or null
getFormattedExpires()source public
getFormattedExpires( )
Builds the expiration value part of the header string
Returns
stringgetId()source public
getId( )
Get the id for a cookie
Cookies are unique across name, domain, path tuples.
Returns
stringisExpired()source public
isExpired( DateTime|DateTimeImmutable $time null )
Check if a cookie is expired when compared to $time
Cookies without an expiration date always return false.
Parameters
- DateTime|DateTimeImmutable
$timeoptional null - The time to test against. Defaults to 'now' in UTC.
Returns
booleanwithDomain()source public
withDomain( string $domain )
Create a cookie with an updated domain
Parameters
- string
$domain - Domain to set
Returns
Cake\Http\Cookie\CookieInterfacewithExpired()source public
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
Returns
Cake\Http\Cookie\CookieInterfacewithExpiry()source public
withExpiry( DateTime|DateTimeImmutable $dateTime )
Create a cookie with an updated expiration date
Parameters
- DateTime|DateTimeImmutable
$dateTime - Date time object
Returns
Cake\Http\Cookie\CookieInterfacewithHttpOnly()source public
withHttpOnly( boolean $httpOnly )
Create a cookie with HTTP Only updated
Parameters
- boolean
$httpOnly - HTTP Only
Returns
Cake\Http\Cookie\CookieInterfacewithName()source public
withName( string $name )
Sets the cookie name
Parameters
- string
$name - Name of the cookie
Returns
Cake\Http\Cookie\CookieInterfacewithNeverExpire()source public
withNeverExpire( )
Create a new cookie that will virtually never expire.
Returns
Cake\Http\Cookie\CookieInterfacewithPath()source public
withPath( string $path )
Create a new cookie with an updated path
Parameters
- string
$path - Sets the path
Returns
Cake\Http\Cookie\CookieInterfacewithSecure()source public
withSecure( boolean $secure )
Create a cookie with Secure updated
Parameters
- boolean
$secure - Secure attribute value
Returns
Cake\Http\Cookie\CookieInterfacewithValue()source public
withValue( string|array $value )
Create a cookie with an updated value.
Parameters
- string|array
$value - Value of the cookie to set
Returns
Cake\Http\Cookie\CookieInterface
© 2005–2017 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/3.4/class-Cake.Http.Cookie.CookieInterface.html