PHP Class Neos\Flow\Http\Cookie

See also: http://tools.ietf.org/html/rfc6265
Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$domain string Hosts to which this cookie will be sent (RFC 6265, 4.1.2.3)
$expiresTimestamp integer Unix timestamp of the expiration date / time or 0 for "session" expiration (RFC 6265, 4.1.2.1)
$httpOnly boolean
$maximumAge integer Number of seconds until the cookie expires (RFC 6265, 4.1.2.2)
$name string Cookie Name, a token (RFC 6265, 4.1.1)
$path string
$secure boolean
$value string

Public Methods

Method Description
__construct ( string $name, mixed $value = null, integer | DateTime $expires, integer $maximumAge = null, string $domain = null, string $path = '/', boolean $secure = false, boolean $httpOnly = true ) Constructs a new Cookie object
__toString ( ) : string Renders the field value suitable for a HTTP "Set-Cookie" header.
createFromRawSetCookieHeader ( string $header ) : Cookie Creates a cookie (an instance of this class) by a provided raw header string like "foo=507d9f20317a5; path=/; domain=.example.org" This is is an implementation of the algorithm explained in RFC 6265, Section 5.2 A basic statement of this algorithm is to "ignore the set-cookie-string entirely" in case a required condition is not met. In these cases this function will return NULL rather than the created cookie.
expire ( ) : void Marks this cookie for removal.
getDomain ( ) : string Returns the domain this cookie is valid for.
getExpires ( ) : integer Returns the date and time of the Expires attribute, if any.
getMaximumAge ( ) : integer Returns the number of seconds until the cookie expires, if defined.
getName ( ) : string Returns the name of this cookie
getPath ( ) : string Returns the path this cookie is valid for.
getValue ( ) : mixed Returns the value of this cookie
isExpired ( ) : boolean Tells if this cookie is expired and will be removed in the user agent when it received the response containing this cookie.
isHttpOnly ( ) : boolean Tells if this cookie should only be used through the HTTP protocol.
isSecure ( ) : boolean Tells if the cookie was flagged to be sent over "secure" channels only.
setValue ( mixed $value ) : void Sets the value of this cookie

Method Details

__construct() public method

Constructs a new Cookie object
public __construct ( string $name, mixed $value = null, integer | DateTime $expires, integer $maximumAge = null, string $domain = null, string $path = '/', boolean $secure = false, boolean $httpOnly = true )
$name string The cookie name as a valid token (RFC 2616)
$value mixed The value to store in the cookie. Must be possible to cast into a string.
$expires integer | DateTime Date and time after which this cookie expires.
$maximumAge integer Number of seconds until the cookie expires.
$domain string The host to which the user agent will send this cookie
$path string The path describing the scope of this cookie
$secure boolean If this cookie should only be sent through a "secure" channel by the user agent
$httpOnly boolean If this cookie should only be used through the HTTP protocol

__toString() public method

Renders the field value suitable for a HTTP "Set-Cookie" header.
public __toString ( ) : string
return string

createFromRawSetCookieHeader() public static method

Creates a cookie (an instance of this class) by a provided raw header string like "foo=507d9f20317a5; path=/; domain=.example.org" This is is an implementation of the algorithm explained in RFC 6265, Section 5.2 A basic statement of this algorithm is to "ignore the set-cookie-string entirely" in case a required condition is not met. In these cases this function will return NULL rather than the created cookie.
See also: http://tools.ietf.org/html/rfc6265
public static createFromRawSetCookieHeader ( string $header ) : Cookie
$header string The Set-Cookie string without the actual "Set-Cookie:" part
return Cookie

expire() public method

On executing this method, the expiry time of this cookie is set to a point in time in the past triggers the removal of the cookie in the user agent.
public expire ( ) : void
return void

getDomain() public method

Returns the domain this cookie is valid for.
public getDomain ( ) : string
return string The domain name

getExpires() public method

Note that this date / time is returned as a unix timestamp, no matter what the format was originally set through the constructor of this Cookie. The special case "no expiration time" is returned in form of a zero value.
public getExpires ( ) : integer
return integer A unix timestamp or 0

getMaximumAge() public method

This information is rendered as the Max-Age attribute (RFC 6265, 4.1.2.2). Note that not all browsers support this attribute.
public getMaximumAge ( ) : integer
return integer The maximum age in seconds, or NULL if none has been defined.

getName() public method

Returns the name of this cookie
public getName ( ) : string
return string The cookie name

getPath() public method

Returns the path this cookie is valid for.
public getPath ( ) : string
return string The path

getValue() public method

Returns the value of this cookie
public getValue ( ) : mixed
return mixed

isExpired() public method

Tells if this cookie is expired and will be removed in the user agent when it received the response containing this cookie.
public isExpired ( ) : boolean
return boolean True if this cookie is expired

isHttpOnly() public method

Tells if this cookie should only be used through the HTTP protocol.
public isHttpOnly ( ) : boolean
return boolean State of the "HttpOnly" attribute

isSecure() public method

This security measure only has a limited effect. Please read RFC 6265 Section 8.6 for more details.
public isSecure ( ) : boolean
return boolean State of the "Secure" attribute

setValue() public method

Sets the value of this cookie
public setValue ( mixed $value ) : void
$value mixed The new value
return void

Property Details

$domain protected property

Hosts to which this cookie will be sent (RFC 6265, 4.1.2.3)
protected string $domain
return string

$expiresTimestamp protected property

Unix timestamp of the expiration date / time or 0 for "session" expiration (RFC 6265, 4.1.2.1)
protected int $expiresTimestamp
return integer

$httpOnly protected property

protected bool $httpOnly
return boolean

$maximumAge protected property

Number of seconds until the cookie expires (RFC 6265, 4.1.2.2)
protected int $maximumAge
return integer

$name protected property

Cookie Name, a token (RFC 6265, 4.1.1)
protected string $name
return string

$path protected property

protected string $path
return string

$secure protected property

protected bool $secure
return boolean

$value protected property

protected string $value
return string