Interface CookieInterface

Cookie Interface

Direct Implementers

Constants summary

  • string

    EXPIRES_FORMAT
    'D, d-M-Y H:i:s T'

Method Summary

Method Detail

getDomain()source public

getDomain( )

Get the domain attribute.

Returns

string

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|null
The expiry time as a string timestamp.

getExpiry()source public

getExpiry( )

Get the current expiry time

Returns

DateTime|DateTimeImmutable|null
Timestamp of expiry or null

getFormattedExpires()source public

getFormattedExpires( )

Builds the expiration value part of the header string

Returns

string

getId()source public

getId( )

Get the id for a cookie

Cookies are unique across name, domain, path tuples.

Returns

string

getName()source public

getName( )

Gets the cookie name

Returns

string

getPath()source public

getPath( )

Get the path attribute.

Returns

string

getStringValue()source public

getStringValue( )

Gets the cookie value as a string.

This will collapse any complex data in the cookie with json_encode()

Returns

string

getValue()source public

getValue( )

Gets the cookie value

Returns

string|array

isExpired()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 $time optional null
The time to test against. Defaults to 'now' in UTC.

Returns

boolean

isHttpOnly()source public

isHttpOnly( )

Check if the cookie is HTTP only

Returns

boolean

isSecure()source public

isSecure( )

Check if the cookie is secure

Returns

boolean

toHeaderValue()source public

toHeaderValue( )

Returns the cookie as header value

Returns

string

withDomain()source public

withDomain( string $domain )

Create a cookie with an updated domain

Parameters

string $domain
Domain to set

Returns

Cake\Http\Cookie\CookieInterface

withExpired()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\CookieInterface

withExpiry()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\CookieInterface

withHttpOnly()source public

withHttpOnly( boolean $httpOnly )

Create a cookie with HTTP Only updated

Parameters

boolean $httpOnly
HTTP Only

Returns

Cake\Http\Cookie\CookieInterface

withName()source public

withName( string $name )

Sets the cookie name

Parameters

string $name
Name of the cookie

Returns

Cake\Http\Cookie\CookieInterface

withNeverExpire()source public

withNeverExpire( )

Create a new cookie that will virtually never expire.

Returns

Cake\Http\Cookie\CookieInterface

withPath()source public

withPath( string $path )

Create a new cookie with an updated path

Parameters

string $path
Sets the path

Returns

Cake\Http\Cookie\CookieInterface

withSecure()source public

withSecure( boolean $secure )

Create a cookie with Secure updated

Parameters

boolean $secure
Secure attribute value

Returns

Cake\Http\Cookie\CookieInterface

withValue()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–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/3.8/class-Cake.Http.Cookie.CookieInterface.html