CloneableCookieInterface
extends
CookieInterface
in
Interface for a fresh Cookie instance with selected attribute(s) only changed from the original instance.
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.
- 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
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
Return values
stringwithDomain()
Creates a new Cookie with a new domain the cookie is available.
public
withDomain(string|null $domain) : static
Parameters
- $domain : string|null
Return values
staticwithExpired()
Creates a new Cookie that will expire the cookie from the browser.
public
withExpired() : static
Return values
staticwithExpires()
Creates a new Cookie with a new cookie expires time.
public
withExpires(DateTimeInterface|int|string $expires) : static
Parameters
- $expires : DateTimeInterface|int|string
Return values
staticwithHTTPOnly()
Creates a new Cookie with a new "HttpOnly" attribute
public
withHTTPOnly([bool $httponly = true ]) : static
Parameters
- $httponly : bool = true
Return values
staticwithName()
Creates a new Cookie with a new name.
public
withName(string $name) : static
Parameters
- $name : string
Return values
staticwithNeverExpiring()
Creates a new Cookie that will virtually never expire from the browser.
public
withNeverExpiring() : static
See https://github.com/codeigniter4/CodeIgniter4/pull/6413
Return values
staticwithPath()
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
staticwithPrefix()
Creates a new Cookie with a new cookie prefix.
public
withPrefix([string $prefix = '' ]) : static
Parameters
- $prefix : string = ''
Return values
staticwithRaw()
Creates a new Cookie with URL encoding option updated.
public
withRaw([bool $raw = true ]) : static
Parameters
- $raw : bool = true
Return values
staticwithSameSite()
Creates a new Cookie with a new "SameSite" attribute.
public
withSameSite(string $samesite) : static
Parameters
- $samesite : string
Return values
staticwithSecure()
Creates a new Cookie with a new "Secure" attribute.
public
withSecure([bool $secure = true ]) : static
Parameters
- $secure : bool = true
Return values
staticwithValue()
Creates a new Cookie with new value.
public
withValue(string $value) : static
Parameters
- $value : string