Cookie
in package
Represents a cookie.
Tags
Table of Contents
- SAMESITE_LAX = 'lax'
- SAMESITE_NONE = 'none'
- SAMESITE_STRICT = 'strict'
- $domain : mixed
- $expire : mixed
- $httpOnly : mixed
- $name : mixed
- $path : mixed
- $secure : mixed
- $value : mixed
- $raw : mixed
- $reservedCharsFrom : mixed
- $reservedCharsList : mixed
- $reservedCharsTo : mixed
- $sameSite : mixed
- __construct() : mixed
- __toString() : string
- Returns the cookie as a string.
- fromString() : static
- Creates cookie from raw header string.
- getDomain() : string|null
- Gets the domain that the cookie is available to.
- getExpiresTime() : int
- Gets the time the cookie expires.
- getMaxAge() : int
- Gets the max-age attribute.
- getName() : string
- Gets the name of the cookie.
- getPath() : string
- Gets the path on the server in which the cookie will be available on.
- getSameSite() : string|null
- Gets the SameSite attribute.
- getValue() : string|null
- Gets the value of the cookie.
- isCleared() : bool
- Whether this cookie is about to be cleared.
- isHttpOnly() : bool
- Checks whether the cookie will be made accessible only through the HTTP protocol.
- isRaw() : bool
- Checks if the cookie value should be sent with no url encoding.
- isSecure() : bool
- Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
Constants
SAMESITE_LAX
public
mixed
SAMESITE_LAX
= 'lax'
SAMESITE_NONE
public
mixed
SAMESITE_NONE
= 'none'
SAMESITE_STRICT
public
mixed
SAMESITE_STRICT
= 'strict'
Properties
$domain
protected
mixed
$domain
$expire
protected
mixed
$expire
$httpOnly
protected
mixed
$httpOnly
$name
protected
mixed
$name
$path
protected
mixed
$path
$secure
protected
mixed
$secure
$value
protected
mixed
$value
$raw
private
mixed
$raw
$reservedCharsFrom
private
static mixed
$reservedCharsFrom
= ['=', ',', ';', ' ', " ", "
", "
", "", ""]
$reservedCharsList
private
static mixed
$reservedCharsList
= "=,;
"
$reservedCharsTo
private
static mixed
$reservedCharsTo
= ['%3D', '%2C', '%3B', '%20', '%09', '%0D', '%0A', '%0B', '%0C']
$sameSite
private
mixed
$sameSite
Methods
__construct()
public
__construct(string $name[, string|null $value = null ], int|string|DateTimeInterface $expire[, string $path = '/' ][, string|null $domain = null ][, bool $secure = false ][, bool $httpOnly = true ][, bool $raw = false ][, string|null $sameSite = null ]) : mixed
Parameters
- $name : string
-
The name of the cookie
- $value : string|null = null
-
The value of the cookie
- $expire : int|string|DateTimeInterface
-
The time the cookie expires
- $path : string = '/'
-
The path on the server in which the cookie will be available on
- $domain : string|null = null
-
The domain that the cookie is available to
- $secure : bool = false
-
Whether the cookie should only be transmitted over a secure HTTPS connection from the client
- $httpOnly : bool = true
-
Whether the cookie will be made accessible only through the HTTP protocol
- $raw : bool = false
-
Whether the cookie value should be sent with no url encoding
- $sameSite : string|null = null
-
Whether the cookie will be available for cross-site requests
Tags
Return values
mixed —__toString()
Returns the cookie as a string.
public
__toString() : string
Return values
string —The cookie
fromString()
Creates cookie from raw header string.
public
static fromString(string $cookie[, bool $decode = false ]) : static
Parameters
- $cookie : string
- $decode : bool = false
Return values
static —getDomain()
Gets the domain that the cookie is available to.
public
getDomain() : string|null
Return values
string|null —getExpiresTime()
Gets the time the cookie expires.
public
getExpiresTime() : int
Return values
int —getMaxAge()
Gets the max-age attribute.
public
getMaxAge() : int
Return values
int —getName()
Gets the name of the cookie.
public
getName() : string
Return values
string —getPath()
Gets the path on the server in which the cookie will be available on.
public
getPath() : string
Return values
string —getSameSite()
Gets the SameSite attribute.
public
getSameSite() : string|null
Return values
string|null —getValue()
Gets the value of the cookie.
public
getValue() : string|null
Return values
string|null —isCleared()
Whether this cookie is about to be cleared.
public
isCleared() : bool
Return values
bool —isHttpOnly()
Checks whether the cookie will be made accessible only through the HTTP protocol.
public
isHttpOnly() : bool
Return values
bool —isRaw()
Checks if the cookie value should be sent with no url encoding.
public
isRaw() : bool
Return values
bool —isSecure()
Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
public
isSecure() : bool