Cookie
in package
Cookie represents an HTTP cookie.
Tags
Table of Contents
Properties
- $domain : mixed
- $expires : mixed
- $httponly : mixed
- $name : mixed
- $path : mixed
- $rawValue : mixed
- $secure : mixed
- $value : mixed
- $dateFormats : mixed
- Handles dates as defined by RFC 2616 section 3.3.1, and also some other non-standard, but common formats.
Methods
- __construct() : mixed
- Sets a cookie.
- __toString() : mixed
- Returns the HTTP representation of the Cookie.
- fromString() : static
- Creates a Cookie instance from a Set-Cookie header value.
- getDomain() : string
- Gets the domain of the cookie.
- getExpiresTime() : string|null
- Gets the expires time of the cookie.
- getName() : string
- Gets the name of the cookie.
- getPath() : string
- Gets the path of the cookie.
- getRawValue() : string
- Gets the raw value of the cookie.
- getValue() : string
- Gets the value of the cookie.
- isExpired() : bool
- Returns true if the cookie has expired.
- isHttpOnly() : bool
- Returns the httponly flag of the cookie.
- isSecure() : bool
- Returns the secure flag of the cookie.
- parseDate() : string|null
Properties
$domain
protected
mixed
$domain
$expires
protected
mixed
$expires
$httponly
protected
mixed
$httponly
$name
protected
mixed
$name
$path
protected
mixed
$path
$rawValue
protected
mixed
$rawValue
$secure
protected
mixed
$secure
$value
protected
mixed
$value
$dateFormats
Handles dates as defined by RFC 2616 section 3.3.1, and also some other non-standard, but common formats.
private
static mixed
$dateFormats
= ['D, d M Y H:i:s T', 'D, d-M-y H:i:s T', 'D, d-M-Y H:i:s T', 'D, d-m-y H:i:s T', 'D, d-m-Y H:i:s T', 'D M j G:i:s Y', 'D M d H:i:s Y T']
Methods
__construct()
Sets a cookie.
public
__construct(string $name, string $value[, string|null $expires = null ][, string|null $path = null ][, string $domain = '' ][, bool $secure = false ][, bool $httponly = true ][, bool $encodedValue = false ]) : mixed
Parameters
- $name : string
-
The cookie name
- $value : string
-
The value of the cookie
- $expires : string|null = null
-
The time the cookie expires
- $path : string|null = null
-
The path on the server in which the cookie will be available on
- $domain : string = ''
-
The domain that the cookie is available
- $secure : bool = false
-
Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
- $httponly : bool = true
-
The cookie httponly flag
- $encodedValue : bool = false
-
Whether the value is encoded or not
__toString()
Returns the HTTP representation of the Cookie.
public
__toString() : mixed
fromString()
Creates a Cookie instance from a Set-Cookie header value.
public
static fromString(string $cookie[, string|null $url = null ]) : static
Parameters
- $cookie : string
-
A Set-Cookie header value
- $url : string|null = null
-
The base URL
Tags
Return values
staticgetDomain()
Gets the domain of the cookie.
public
getDomain() : string
Return values
string —The cookie domain
getExpiresTime()
Gets the expires time of the cookie.
public
getExpiresTime() : string|null
Return values
string|null —The cookie expires time
getName()
Gets the name of the cookie.
public
getName() : string
Return values
string —The cookie name
getPath()
Gets the path of the cookie.
public
getPath() : string
Return values
string —The cookie path
getRawValue()
Gets the raw value of the cookie.
public
getRawValue() : string
Return values
string —The cookie value
getValue()
Gets the value of the cookie.
public
getValue() : string
Return values
string —The cookie value
isExpired()
Returns true if the cookie has expired.
public
isExpired() : bool
Return values
bool —true if the cookie has expired, false otherwise
isHttpOnly()
Returns the httponly flag of the cookie.
public
isHttpOnly() : bool
Return values
bool —The cookie httponly flag
isSecure()
Returns the secure flag of the cookie.
public
isSecure() : bool
Return values
bool —The cookie secure flag
parseDate()
private
static parseDate(string $dateValue) : string|null
Parameters
- $dateValue : string