Documentation

Cookie
in package

FinalYes

Cookie Value Object.

Tags
author

Márk Sági-Kazár mark.sagikazar@gmail.com

see
http://tools.ietf.org/search/rfc6265

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

$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
throws
InvalidArgumentException

if name, value or max age is not valid

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|null

getExpires()

Returns the expiration time.

public getExpires() : DateTime|null
Return values
DateTime|null

getMaxAge()

Returns the max age.

public getMaxAge() : int|null
Return values
int|null

getName()

Returns the name.

public getName() : string
Return values
string

getPath()

Returns the path.

public getPath() : string
Return values
string

getValue()

Returns the value.

public getValue() : string|null
Return values
string|null

hasDomain()

Checks if there is a domain.

public hasDomain() : bool
Return values
bool

hasExpires()

Checks if there is an expiration time.

public hasExpires() : bool
Return values
bool

hasMaxAge()

Checks if there is a max age.

public hasMaxAge() : bool
Return values
bool

hasValue()

Checks if there is a value.

public hasValue() : bool
Return values
bool

isExpired()

Checks if the cookie is expired.

public isExpired() : bool
Return values
bool

isHttpOnly()

Check whether this cookie may not be accessed through Javascript.

public isHttpOnly() : bool
Return values
bool

isSecure()

Checks whether this cookie may only be sent over HTTPS.

public isSecure() : bool
Return values
bool

isValid()

Validates cookie attributes.

public isValid() : bool
Return values
bool

match()

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
bool

withDomain()

Sets the domain.

public withDomain(string|null $domain) : Cookie
Parameters
$domain : string|null
Return values
Cookie

withExpires()

Sets the expires.

public withExpires([DateTime|null $expires = null ]) : Cookie
Parameters
$expires : DateTime|null = null
Return values
Cookie

withHttpOnly()

Sets whether this cookie may not be accessed through Javascript.

public withHttpOnly(bool $httpOnly) : Cookie
Parameters
$httpOnly : bool
Return values
Cookie

withMaxAge()

Sets the max age.

public withMaxAge(int|null $maxAge) : Cookie
Parameters
$maxAge : int|null
Return values
Cookie

withPath()

Sets the path.

public withPath(string|null $path) : Cookie
Parameters
$path : string|null
Return values
Cookie

withSecure()

Sets whether this cookie should only be sent over HTTPS.

public withSecure(bool $secure) : Cookie
Parameters
$secure : bool
Return values
Cookie

withValue()

Sets the value.

public withValue(string|null $value) : Cookie
Parameters
$value : string|null
Return values
Cookie

validateMaxAge()

Validates a Max-Age attribute.

private validateMaxAge(int|null $maxAge) : mixed
Parameters
$maxAge : int|null
Tags
throws
InvalidArgumentException

if the Max-Age is not an empty or integer value


        
On this page

Search results