Http/CookieJar.php
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Http
- Subpackage
- CookieJar
- Version
- $Id$
\Zend_Http_CookieJar
- Implements
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Link
- for some specs.
Constants
COOKIE_STRING_CONCAT
= 2
Properties
Methods
_flattenCookiesArray(\Zend_Http_Cookie | array $ptr, int $ret_as = self::COOKIE_OBJECT) : array | string
Helper function to recursivly flatten an array. Shoud be used when exporting the cookies array (or parts of it)
Name | Type | Description |
---|---|---|
$ptr | \Zend_Http_Cookie | array | |
$ret_as | int | What value to return |
Type | Description |
---|---|
array | string |
_matchDomain(string $domain) : array
Return a subset of the cookies array matching a specific domain
Name | Type | Description |
---|---|---|
$domain | string |
Type | Description |
---|---|
array |
_matchPath( $domains, string $path) : array
Return a subset of a domain-matching cookies that also match a specified path
Name | Type | Description |
---|---|---|
$domains | ||
$path | string |
Type | Description |
---|---|
array |
addCookie(\Zend_Http_Cookie | string $cookie, \Zend_Uri_Http | string $ref_uri = null, boolean $encodeValue = true) : void
Add a cookie to the jar. Cookie should be passed either as a Zend_Http_Cookie object or as a string - in which case an object is created from the string.
Name | Type | Description |
---|---|---|
$cookie | \Zend_Http_Cookie | string | |
$ref_uri | \Zend_Uri_Http | string | Optional reference URI (for domain, path, secure) |
$encodeValue | boolean |
addCookiesFromResponse(\Zend_Http_Response $response, \Zend_Uri_Http | string $ref_uri, boolean $encodeValue = true) : void
Parse an HTTP response, adding all the cookies set in that response to the cookie jar.
Name | Type | Description |
---|---|---|
$response | \Zend_Http_Response | |
$ref_uri | \Zend_Uri_Http | string | Requested URI |
$encodeValue | boolean |
fromResponse(\Zend_Http_Response $response, $ref_uri) : \Zend_Http_CookieJar
Create a new CookieJar object and automatically load into it all the cookies set in an Http_Response object. If $uri is set, it will be considered as the requested URI for setting default domain and path of the cookie.
Name | Type | Description |
---|---|---|
$response | \Zend_Http_Response | HTTP Response object |
$ref_uri |
Type | Description |
---|---|
\Zend_Http_CookieJar |
- Todo
- Add the $uri functionality.
getAllCookies(int $ret_as = self::COOKIE_OBJECT) : array | string
Get all cookies in the cookie jar as an array
Name | Type | Description |
---|---|---|
$ret_as | int | Whether to return cookies as objects of Zend_Http_Cookie or as strings |
Type | Description |
---|---|
array | string |
getCookie(\Zend_Uri_Http | string $uri, string $cookie_name, int $ret_as = self::COOKIE_OBJECT) : \Zend_Http_Cookie | string
Get a specific cookie according to a URI and name
Name | Type | Description |
---|---|---|
$uri | \Zend_Uri_Http | string | The uri (domain and path) to match |
$cookie_name | string | The cookie's name |
$ret_as | int | Whether to return cookies as objects of Zend_Http_Cookie or as strings |
Type | Description |
---|---|
\Zend_Http_Cookie | string |
getIterator() : \ArrayIterator
Required by IteratorAggregate interface
Type | Description |
---|---|
\ArrayIterator |
getMatchingCookies(string | \Zend_Uri_Http $uri, boolean $matchSessionCookies = true, int $ret_as = self::COOKIE_OBJECT, int $now = null) : array | string
Return an array of all cookies matching a specific request according to the request URI, whether session cookies should be sent or not, and the time to consider as "now" when checking cookie expiry time.
Name | Type | Description |
---|---|---|
$uri | string | \Zend_Uri_Http | URI to check against (secure, domain, path) |
$matchSessionCookies | boolean | Whether to send session cookies |
$ret_as | int | Whether to return cookies as objects of Zend_Http_Cookie or as strings |
$now | int | Override the current time when checking for expiry time |
Type | Description |
---|---|
array | string |
reset() : \Zend_Http_CookieJar
Empties the cookieJar of any cookie
Type | Description |
---|---|
\Zend_Http_CookieJar |