\Zend_Http_CookieJar
A Zend_Http_CookieJar object is designed to contain and maintain HTTP cookies, and should be used along with Zend_Http_Client in order to manage cookies across HTTP requests and responses.
The class contains an array of Zend_Http_Cookie objects. Cookies can be added to the jar
automatically from a request or manually. Then, the jar can find and return the cookies
needed for a specific HTTP request.
A special parameter can be passed to all methods of this class that return cookies: Cookies
can be returned either in their native form (as Zend_Http_Cookie objects) or as strings -
the later is suitable for sending as the value of the "Cookie" header in an HTTP request.
You can also choose, when returning more than one cookie, whether to get an array of strings
(by passing Zend_Http_CookieJar::COOKIE_STRING_ARRAY) or one unified string for all cookies
(by passing Zend_Http_CookieJar::COOKIE_STRING_CONCAT).
- Copyright: Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
- License: http://framework.zend.com/license/new-bsd New BSD License
Synopsis
class Zend_Http_CookieJar
implements
Countable,IteratorAggregate
{
- // constants
- const COOKIE_OBJECT = 0;
- const COOKIE_STRING_ARRAY = 1;
- const COOKIE_STRING_CONCAT = 2;
- // members
- protected array $cookies = ;
- protected array $_rawCookies = ;
- // methods
- public void __construct()
- public void addCookie()
- public void addCookiesFromResponse()
- public array|string getAllCookies()
- public array|string getMatchingCookies()
- public Zend_Http_Cookie|string getCookie()
- protected array|string _flattenCookiesArray()
- protected array _matchDomain()
- protected array _matchPath()
- public static Zend_Http_CookieJar fromResponse()
- public int count()
- public ArrayIterator getIterator()
- public bool isEmpty()
- public Zend_Http_CookieJar reset()
Hierarchy
Implements
Tasks
Line | Task |
---|---|
370+ | Add the $uri functionality. |
Constants
Name | Value |
---|---|
COOKIE_OBJECT | 0 |
COOKIE_STRING_ARRAY | 1 |
COOKIE_STRING_CONCAT | 2 |
Members
protected
- $_rawCookies
—
array
The Zend_Http_Cookie array
Methods
protected
- _flattenCookiesArray() — Helper function to recursivly flatten an array. Shoud be used when exporting the cookies array (or parts of it)
- _matchDomain() — Return a subset of the cookies array matching a specific domain
- _matchPath() — Return a subset of a domain-matching cookies that also match a specified path
public
- __construct() — Construct a new CookieJar object
- addCookie() — 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.
- addCookiesFromResponse() — Parse an HTTP response, adding all the cookies set in that response to the cookie jar.
- count() — Required by Countable interface
- fromResponse() — 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.
- getAllCookies() — Get all cookies in the cookie jar as an array
- getCookie() — Get a specific cookie according to a URI and name
- getIterator() — Required by IteratorAggregate interface
- getMatchingCookies() — 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.
- isEmpty() — Tells if the jar is empty of any cookie
- reset() — Empties the cookieJar of any cookie