CookieInterface
in
Interface for a value object representation of an HTTP cookie.
Tags
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
ALLOWED_SAMESITE_VALUES
RFC 6265 allowed values for the "SameSite" attribute.
public
mixed
ALLOWED_SAMESITE_VALUES
= [self::SAMESITE_NONE, self::SAMESITE_LAX, self::SAMESITE_STRICT]
Tags
EXPIRES_FORMAT
Expires date format.
public
mixed
EXPIRES_FORMAT
= 'D, d-M-Y H:i:s T'
Tags
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
stringgetDomain()
Gets the "Domain" cookie attribute.
public
getDomain() : string
Return values
stringgetExpiresString()
Gets the formatted expires time.
public
getExpiresString() : string
Return values
stringgetExpiresTimestamp()
Gets the time in Unix timestamp the cookie expires.
public
getExpiresTimestamp() : int
Return values
intgetId()
Returns a unique identifier for the cookie consisting of its prefixed name, path, and domain.
public
getId() : string
Return values
stringgetMaxAge()
Gets the "Max-Age" cookie attribute.
public
getMaxAge() : int
Return values
intgetName()
Gets the cookie name.
public
getName() : string
Return values
stringgetOptions()
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
stringgetPrefix()
Gets the cookie prefix.
public
getPrefix() : string
Return values
stringgetPrefixedName()
Gets the cookie name prepended with the prefix, if any.
public
getPrefixedName() : string
Return values
stringgetSameSite()
Gets the "SameSite" cookie attribute.
public
getSameSite() : string
Return values
stringgetValue()
Gets the cookie value.
public
getValue() : string
Return values
stringisExpired()
Checks if the cookie is expired.
public
isExpired() : bool
Return values
boolisHTTPOnly()
Gets the "HttpOnly" cookie attribute.
public
isHTTPOnly() : bool
Checks if JavaScript is forbidden from accessing the cookie.
Return values
boolisRaw()
Checks if the cookie should be sent with no URL encoding.
public
isRaw() : bool
Return values
boolisSecure()
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
booltoArray()
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