Zend_Http_Cookie is a class describing an HTTP cookie and all it's parameters.

Zend_Http_Cookie is a class describing an HTTP cookie and all it's parameters. The class also enables validating whether the cookie should be sent to the server in a specified scenario according to the request URI, the expiry time and whether session cookies should be used or not. Generally speaking cookies should be contained in a Cookiejar object, or instantiated manually and added to an HTTP request.

See http://wp.netscape.com/newsref/std/cookie_spec.html for some specs.

category Zend
package Zend_Http
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Cookie object constructor

__construct(string $name, string $value, string $domain, integer $expires = null, string $path = null, boolean $secure = false
todo Add validation of each one of the parameters (legal domain, etc.)

Parameters

$name

string

$value

string

$domain

string

$expires

integer

$path

string

$secure

boolean

Get the cookie as a string, suitable for sending as a "Cookie" header in an HTTP request

__toString() : string

Returns

string

Generate a new Cookie object from a cookie string (for example the value of the Set-Cookie HTTP header)

fromString(string $cookieStr, \Zend_Uri_Http|string $refUri = null, boolean $encodeValue = true) : \Zend_Http_Cookie
Static

Parameters

$cookieStr

string

$refUri

\Zend_Uri_Httpstring

Reference URI for default values (domain, path)

$encodeValue

boolean

Whether or not the cookie's value should be passed through urlencode/urldecode

Returns

\Zend_Http_CookieA new Zend_Http_Cookie object or false on failure.

Get cookie domain

getDomain() : string

Returns

string

Get the expiry time of the cookie, or null if no expiry time is set

getExpiryTime() : integer | null

Returns

integernull

Get Cookie name

getName() : string

Returns

string

Get the cookie path

getPath() : string

Returns

string

Get cookie value

getValue() : string

Returns

string

Check whether the cookie has expired

isExpired(integer $now = null) : boolean

Always returns false if the cookie is a session cookie (has no expiry time)

Parameters

$now

integer

Timestamp to consider as "now"

Returns

boolean

Check whether the cookie should only be sent over secure connections

isSecure() : boolean

Returns

boolean

Check whether the cookie is a session cookie (has no expiry time set)

isSessionCookie() : boolean

Returns

boolean

Checks whether the cookie should be sent or not in a specific scenario

match(string|\Zend_Uri_Http $uri, boolean $matchSessionCookies = true, integer $now = null) : boolean

Parameters

$uri

string\Zend_Uri_Http

URI to check against (secure, domain, path)

$matchSessionCookies

boolean

Whether to send session cookies

$now

integer

Override the current time when checking for expiry time

Returns

boolean

Check if a cookie's domain matches a host name.

matchCookieDomain(string $cookieDomain, string $host) : boolean
Static

Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching

Parameters

$cookieDomain

string

$host

string

Returns

boolean

Check if a cookie's path matches a URL path

matchCookiePath(string $cookiePath, string $path) : boolean
Static

Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching

Parameters

$cookiePath

string

$path

string

Returns

boolean

 Properties

 

Cookie domain

$domain : string

Default

 

Whether the cookie value has been encoded/decoded

$encodeValue : boolean

Default

 

Cookie expiry date

$expires : integer

Default

 

Cookie name

$name : string

Default

 

Cookie path

$path : string

Default

 

Whether the cookie is secure or not

$secure : boolean

Default

 

Cookie value

$value : string

Default