CodeIgniter v4.5 API

CookieInterface

Interface for a value object representation of an HTTP cookie.

Tags
see
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie

Table of Contents

Constants

ALLOWED_SAMESITE_VALUES  = [self::SAMESITE_NONE, self::SAMESITE_LAX, self::SAMESITE_STRICT]
RFC 6265 allowed values for the "SameSite" attribute.
EXPIRES_FORMAT  = 'D, d-M-Y H:i:s T'
Expires date format.
SAMESITE_LAX  = 'lax'
Cookies are not sent on normal cross-site subrequests (for example to load images or frames into a third party site), but are sent when a user is navigating to the origin site (i.e. when following a link).
SAMESITE_NONE  = 'none'
Cookies will be sent in all contexts, i.e in responses to both first-party and cross-origin requests. If `SameSite=None` is set, the cookie `Secure` attribute must also be set (or the cookie will be blocked).
SAMESITE_STRICT  = 'strict'
Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites.

Methods

__toString()  : string
Returns the string representation of the Cookie object.
getDomain()  : string
Gets the "Domain" cookie attribute.
getExpiresString()  : string
Gets the formatted expires time.
getExpiresTimestamp()  : int
Gets the time in Unix timestamp the cookie expires.
getId()  : string
Returns a unique identifier for the cookie consisting of its prefixed name, path, and domain.
getMaxAge()  : int
Gets the "Max-Age" cookie attribute.
getName()  : string
Gets the cookie name.
getOptions()  : array<string, bool|int|string>
Gets the options that are passable to the `setcookie` variant available on PHP 7.3+
getPath()  : string
Gets the "Path" cookie attribute.
getPrefix()  : string
Gets the cookie prefix.
getPrefixedName()  : string
Gets the cookie name prepended with the prefix, if any.
getSameSite()  : string
Gets the "SameSite" cookie attribute.
getValue()  : string
Gets the cookie value.
isExpired()  : bool
Checks if the cookie is expired.
isHTTPOnly()  : bool
Gets the "HttpOnly" cookie attribute.
isRaw()  : bool
Checks if the cookie should be sent with no URL encoding.
isSecure()  : bool
Gets the "Secure" cookie attribute.
toArray()  : array<string, bool|int|string>
Returns the array representation of the Cookie object.
toHeaderString()  : string
Returns the Cookie as a header value.

Constants

SAMESITE_LAX

Cookies are not sent on normal cross-site subrequests (for example to load images or frames into a third party site), but are sent when a user is navigating to the origin site (i.e. when following a link).

public mixed SAMESITE_LAX = 'lax'

SAMESITE_NONE

Cookies will be sent in all contexts, i.e in responses to both first-party and cross-origin requests. If `SameSite=None` is set, the cookie `Secure` attribute must also be set (or the cookie will be blocked).

public mixed SAMESITE_NONE = 'none'

SAMESITE_STRICT

Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites.

public mixed SAMESITE_STRICT = 'strict'

Methods

__toString()

Returns the string representation of the Cookie object.

public __toString() : string
Return values
string

getDomain()

Gets the "Domain" cookie attribute.

public getDomain() : string
Return values
string

getExpiresString()

Gets the formatted expires time.

public getExpiresString() : string
Return values
string

getExpiresTimestamp()

Gets the time in Unix timestamp the cookie expires.

public getExpiresTimestamp() : int
Return values
int

getId()

Returns a unique identifier for the cookie consisting of its prefixed name, path, and domain.

public getId() : string
Return values
string

getMaxAge()

Gets the "Max-Age" cookie attribute.

public getMaxAge() : int
Return values
int

getName()

Gets the cookie name.

public getName() : string
Return values
string

getOptions()

Gets the options that are passable to the `setcookie` variant available on PHP 7.3+

public getOptions() : array<string, bool|int|string>
Return values
array<string, bool|int|string>

getPath()

Gets the "Path" cookie attribute.

public getPath() : string
Return values
string

getPrefix()

Gets the cookie prefix.

public getPrefix() : string
Return values
string

getPrefixedName()

Gets the cookie name prepended with the prefix, if any.

public getPrefixedName() : string
Return values
string

getSameSite()

Gets the "SameSite" cookie attribute.

public getSameSite() : string
Return values
string

getValue()

Gets the cookie value.

public getValue() : string
Return values
string

isExpired()

Checks if the cookie is expired.

public isExpired() : bool
Return values
bool

isHTTPOnly()

Gets the "HttpOnly" cookie attribute.

public isHTTPOnly() : bool

Checks if JavaScript is forbidden from accessing the cookie.

Return values
bool

isRaw()

Checks if the cookie should be sent with no URL encoding.

public isRaw() : bool
Return values
bool

isSecure()

Gets the "Secure" cookie attribute.

public isSecure() : bool

Checks if the cookie is only sent to the server when a request is made with the https: scheme (except on localhost), and therefore is more resistent to man-in-the-middle attacks.

Return values
bool

toArray()

Returns the array representation of the Cookie object.

public toArray() : array<string, bool|int|string>
Return values
array<string, bool|int|string>

toHeaderString()

Returns the Cookie as a header value.

public toHeaderString() : string
Return values
string

        
On this page

Search results