CloneableCookieInterface
extends
CookieInterface
in
Interface for a fresh Cookie instance with selected attribute(s) only changed from the original instance.
Table of Contents
- 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.
- __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, mixed>
- 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, mixed>
- Returns the array representation of the Cookie object.
- toHeaderString() : string
- Returns the Cookie as a header value.
- withDomain() : static
- Creates a new Cookie with a new domain the cookie is available.
- withExpired() : static
- Creates a new Cookie that will expire the cookie from the browser.
- withExpires() : static
- Creates a new Cookie with a new cookie expires time.
- withHTTPOnly() : static
- Creates a new Cookie with a new "HttpOnly" attribute
- withName() : static
- Creates a new Cookie with a new name.
- withNeverExpiring() : static
- Creates a new Cookie that will virtually never expire from the browser.
- withPath() : static
- Creates a new Cookie with a new path on the server the cookie is available.
- withPrefix() : static
- Creates a new Cookie with a new cookie prefix.
- withRaw() : static
- Creates a new Cookie with URL encoding option updated.
- withSameSite() : static
- Creates a new Cookie with a new "SameSite" attribute.
- withSecure() : static
- Creates a new Cookie with a new "Secure" attribute.
- withValue() : static
- Creates a new Cookie with new 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
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, mixed>
Return values
array<string, mixed> —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, mixed>
Return values
array<string, mixed> —toHeaderString()
Returns the Cookie as a header value.
public
toHeaderString() : string
Return values
string —withDomain()
Creates a new Cookie with a new domain the cookie is available.
public
withDomain(string|null $domain) : static
Parameters
- $domain : string|null
Return values
static —withExpired()
Creates a new Cookie that will expire the cookie from the browser.
public
withExpired() : static
Return values
static —withExpires()
Creates a new Cookie with a new cookie expires time.
public
withExpires(DateTimeInterface|int|string $expires) : static
Parameters
- $expires : DateTimeInterface|int|string
Return values
static —withHTTPOnly()
Creates a new Cookie with a new "HttpOnly" attribute
public
withHTTPOnly([bool $httponly = true ]) : static
Parameters
- $httponly : bool = true
Return values
static —withName()
Creates a new Cookie with a new name.
public
withName(string $name) : static
Parameters
- $name : string
Return values
static —withNeverExpiring()
Creates a new Cookie that will virtually never expire from the browser.
public
withNeverExpiring() : static
Return values
static —withPath()
Creates a new Cookie with a new path on the server the cookie is available.
public
withPath(string|null $path) : static
Parameters
- $path : string|null
Return values
static —withPrefix()
Creates a new Cookie with a new cookie prefix.
public
withPrefix([string $prefix = '' ]) : static
Parameters
- $prefix : string = ''
Return values
static —withRaw()
Creates a new Cookie with URL encoding option updated.
public
withRaw([bool $raw = true ]) : static
Parameters
- $raw : bool = true
Return values
static —withSameSite()
Creates a new Cookie with a new "SameSite" attribute.
public
withSameSite(string $samesite) : static
Parameters
- $samesite : string
Return values
static —withSecure()
Creates a new Cookie with a new "Secure" attribute.
public
withSecure([bool $secure = true ]) : static
Parameters
- $secure : bool = true
Return values
static —withValue()
Creates a new Cookie with new value.
public
withValue(string $value) : static
Parameters
- $value : string