Cookie
in package
Cookie Value Object.
Tags
Table of Contents
Properties
- $domain : string|null
- $expires : DateTime|null
- Expires attribute is HTTP 1.0 only and should be avoided.
- $httpOnly : bool
- $maxAge : int|null
- $name : string
- $path : string
- $secure : bool
- $value : string|null
Methods
- __construct() : mixed
- createWithoutValidation() : mixed
- Creates a new cookie without any attribute validation.
- getDomain() : string|null
- Returns the domain.
- getExpires() : DateTime|null
- Returns the expiration time.
- getMaxAge() : int|null
- Returns the max age.
- getName() : string
- Returns the name.
- getPath() : string
- Returns the path.
- getValue() : string|null
- Returns the value.
- hasDomain() : bool
- Checks if there is a domain.
- hasExpires() : bool
- Checks if there is an expiration time.
- hasMaxAge() : bool
- Checks if there is a max age.
- hasValue() : bool
- Checks if there is a value.
- isExpired() : bool
- Checks if the cookie is expired.
- isHttpOnly() : bool
- Check whether this cookie may not be accessed through Javascript.
- isSecure() : bool
- Checks whether this cookie may only be sent over HTTPS.
- isValid() : bool
- Validates cookie attributes.
- match() : bool
- Checks if this cookie represents the same cookie as $cookie.
- matchDomain() : bool
- Checks whether this cookie is meant for this domain.
- matchPath() : bool
- Checks whether this cookie is meant for this path.
- withDomain() : Cookie
- Sets the domain.
- withExpires() : Cookie
- Sets the expires.
- withHttpOnly() : Cookie
- Sets whether this cookie may not be accessed through Javascript.
- withMaxAge() : Cookie
- Sets the max age.
- withPath() : Cookie
- Sets the path.
- withSecure() : Cookie
- Sets whether this cookie should only be sent over HTTPS.
- withValue() : Cookie
- Sets the value.
- normalizeDomain() : string
- Remove the leading '.' and lowercase the domain as per spec in RFC 6265.
- normalizePath() : string
- Processes path as per spec in RFC 6265.
- validateMaxAge() : mixed
- Validates a Max-Age attribute.
- validateName() : mixed
- Validates the name attribute.
- validateValue() : mixed
- Validates a value.
Properties
$domain
private
string|null
$domain
$expires
Expires attribute is HTTP 1.0 only and should be avoided.
private
DateTime|null
$expires
$httpOnly
private
bool
$httpOnly
$maxAge
private
int|null
$maxAge
$name
private
string
$name
$path
private
string
$path
$secure
private
bool
$secure
$value
private
string|null
$value
Methods
__construct()
public
__construct(string $name[, string|null $value = null ][, int|null $maxAge = null ][, string|null $domain = null ][, string|null $path = null ][, bool $secure = false ][, bool $httpOnly = false ][, DateTime|null $expires = null ]) : mixed
Parameters
- $name : string
- $value : string|null = null
- $maxAge : int|null = null
- $domain : string|null = null
- $path : string|null = null
- $secure : bool = false
- $httpOnly : bool = false
- $expires : DateTime|null = null
-
Expires attribute is HTTP 1.0 only and should be avoided.
Tags
createWithoutValidation()
Creates a new cookie without any attribute validation.
public
static createWithoutValidation(string $name[, string|null $value = null ][, int $maxAge = null ][, string|null $domain = null ][, string|null $path = null ][, bool $secure = false ][, bool $httpOnly = false ][, DateTime|null $expires = null ]) : mixed
Parameters
- $name : string
- $value : string|null = null
- $maxAge : int = null
- $domain : string|null = null
- $path : string|null = null
- $secure : bool = false
- $httpOnly : bool = false
- $expires : DateTime|null = null
-
Expires attribute is HTTP 1.0 only and should be avoided.
getDomain()
Returns the domain.
public
getDomain() : string|null
Return values
string|nullgetExpires()
Returns the expiration time.
public
getExpires() : DateTime|null
Return values
DateTime|nullgetMaxAge()
Returns the max age.
public
getMaxAge() : int|null
Return values
int|nullgetName()
Returns the name.
public
getName() : string
Return values
stringgetPath()
Returns the path.
public
getPath() : string
Return values
stringgetValue()
Returns the value.
public
getValue() : string|null
Return values
string|nullhasDomain()
Checks if there is a domain.
public
hasDomain() : bool
Return values
boolhasExpires()
Checks if there is an expiration time.
public
hasExpires() : bool
Return values
boolhasMaxAge()
Checks if there is a max age.
public
hasMaxAge() : bool
Return values
boolhasValue()
Checks if there is a value.
public
hasValue() : bool
Return values
boolisExpired()
Checks if the cookie is expired.
public
isExpired() : bool
Return values
boolisHttpOnly()
Check whether this cookie may not be accessed through Javascript.
public
isHttpOnly() : bool
Return values
boolisSecure()
Checks whether this cookie may only be sent over HTTPS.
public
isSecure() : bool
Return values
boolisValid()
Validates cookie attributes.
public
isValid() : bool
Return values
boolmatch()
Checks if this cookie represents the same cookie as $cookie.
public
match(self $cookie) : bool
This does not compare the values, only name, domain and path.
Parameters
- $cookie : self
Return values
boolmatchDomain()
Checks whether this cookie is meant for this domain.
public
matchDomain(string $domain) : bool
Parameters
- $domain : string
Tags
Return values
boolmatchPath()
Checks whether this cookie is meant for this path.
public
matchPath(string $path) : bool
Parameters
- $path : string
Tags
Return values
boolwithDomain()
Sets the domain.
public
withDomain(string|null $domain) : Cookie
Parameters
- $domain : string|null
Return values
CookiewithExpires()
Sets the expires.
public
withExpires([DateTime|null $expires = null ]) : Cookie
Parameters
- $expires : DateTime|null = null
Return values
CookiewithHttpOnly()
Sets whether this cookie may not be accessed through Javascript.
public
withHttpOnly(bool $httpOnly) : Cookie
Parameters
- $httpOnly : bool
Return values
CookiewithMaxAge()
Sets the max age.
public
withMaxAge(int|null $maxAge) : Cookie
Parameters
- $maxAge : int|null
Return values
CookiewithPath()
Sets the path.
public
withPath(string|null $path) : Cookie
Parameters
- $path : string|null
Return values
CookiewithSecure()
Sets whether this cookie should only be sent over HTTPS.
public
withSecure(bool $secure) : Cookie
Parameters
- $secure : bool
Return values
CookiewithValue()
Sets the value.
public
withValue(string|null $value) : Cookie
Parameters
- $value : string|null
Return values
CookienormalizeDomain()
Remove the leading '.' and lowercase the domain as per spec in RFC 6265.
private
normalizeDomain(string|null $domain) : string
Parameters
- $domain : string|null
Tags
Return values
stringnormalizePath()
Processes path as per spec in RFC 6265.
private
normalizePath(string|null $path) : string
Parameters
- $path : string|null
Tags
Return values
stringvalidateMaxAge()
Validates a Max-Age attribute.
private
validateMaxAge(int|null $maxAge) : mixed
Parameters
- $maxAge : int|null
Tags
validateName()
Validates the name attribute.
private
validateName(string $name) : mixed
Parameters
- $name : string
Tags
validateValue()
Validates a value.
private
validateValue(string|null $value) : mixed
Parameters
- $value : string|null