Docs For Class Zend_Http_Cookiejar

## Class Zend_Http_Cookiejar

Description

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 and removed from this array in various ways. The jar can also be useful in returning only 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).

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

Located in /Zend/Http/Cookiejar.php (line 44)

Class Constant Summary
COOKIE_OBJECT = 0
COOKIE_STRING_ARRAY = 1
COOKIE_STRING_CONCAT = 2
Variable Summary
array $cookies
Method Summary
static Zend_Http_Cookiejar factory (Zend_Http_Response $response, $ref_uri, Zend_Uri_Http|string $uri)
Zend_Http_Cookiejar __construct ()
void addCookie (Zend_Http_Cookie|string $cookie, [ $ref_uri = null], Zend_Uri_Http|string $red_uri)
void addCookiesFromResponse (Zend_Http_Response $response, Zend_Uri_Http|string $ref_uri)
void deleteAllCookies ()
boolean deleteCookies (string|Zend_Uri_Http $domain, [string $cookie_name = null])
void deleteExpiredCookies ([int $time = null])
void deleteSessionCookies ()
array|string getAllCookies ([int $ret_as = self::COOKIE_OBJECT])
Zend_Http_Cookie|string getCookie (Zend_Uri_Http|string $uri, string $cookie_name, [int $ret_as = self::COOKIE_OBJECT])
array|string getMatchingCookies (string|Zend_Uri_Http $uri, [boolean $matchSessionCookies = true], [int $ret_as = self::COOKIE_OBJECT], [int $now = null])
array|string _flattenCookiesArray (Zend_Http_Cookie|array $ptr, [int $ret_as = self::COOKIE_OBJECT])
array _matchDomain (string $domain)
array _matchPath ( $domains, string $path, array $dom_array)
Variables
array $cookies = array() (line 81)

Array storing cookies

Cookies are stored according to domain and path: $cookies

- / - cookie1 - cookie2

- / - alsocookie

- access: protected

Methods
static method factory (line 400)

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.

- access: public
- todo: Add the $uri functionality.

static Zend_Http_Cookiejar factory (Zend_Http_Response $response, $ref_uri, Zend_Uri_Http|string $uri)

- Zend_Http_Response $response: HTTP Response object
- Zend_Uri_Http|string $uri: The requested URI
- $ref_uri

Constructor __construct (line 87)

Construct a new CookieJar object

- access: public

Zend_Http_Cookiejar __construct ()
addCookie (line 97)

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.

- access: public

void addCookie (Zend_Http_Cookie|string $cookie, [ $ref_uri = null], Zend_Uri_Http|string $red_uri)

- Zend_Http_Cookie|string $cookie
- Zend_Uri_Http|string $red_uri: Optional reference URI (for domain, path, secure)
- $ref_uri

addCookiesFromResponse (line 121)

Parse an HTTP response, adding all the cookies set in that response to the cookie jar.

- access: public

void addCookiesFromResponse (Zend_Http_Response $response, Zend_Uri_Http|string $ref_uri)

- Zend_Http_Response $response
- Zend_Uri_Http|string $ref_uri: Requested URI

deleteAllCookies (line 228)

Remove all cookies from the jar

- access: public

void deleteAllCookies ()
deleteCookies (line 272)

Delete a cookie according to it's name and domain. If no name is specified, all cookies from this domain will be cleared out.

- return: true if cookie was deleted.
- access: public

boolean deleteCookies (string|Zend_Uri_Http $domain, [string $cookie_name = null])

- string|Zend_Uri_Http $domain
- string $cookie_name

deleteExpiredCookies (line 239)

Clear all cookies who's expiry time is older than $time

- access: public

void deleteExpiredCookies ([int $time = null])

- int $time: Expiry time (default is now)

deleteSessionCookies (line 254)

Clear "Session" cookies (cookies without specific expiry time)

- access: public

void deleteSessionCookies ()
getAllCookies (line 140)

Get all cookies in the cookie jar as an array

- access: public

array|string getAllCookies ([int $ret_as = self::COOKIE_OBJECT])

- int $ret_as: Whether to return cookies as objects of Zend_Http_Cookie or as strings

getCookie (line 192)

Get a specific cookie according to a URI and name

- access: public

Zend_Http_Cookie|string getCookie (Zend_Uri_Http|string $uri, string $cookie_name, [int $ret_as = self::COOKIE_OBJECT])

- Zend_Uri_Http|string $uri: The uri (domain and path) to match
- string $cookie_name: The cookie's name
- int $ret_as: Whether to return cookies as objects of Zend_Http_Cookie or as strings

getMatchingCookies (line 157)

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.

- access: public

array|string getMatchingCookies (string|Zend_Uri_Http $uri, [boolean $matchSessionCookies = true], [int $ret_as = self::COOKIE_OBJECT], [int $now = null])

- string|Zend_Uri_Http $uri: URI to check against (secure, domain, path)
- boolean $matchSessionCookies: Whether to send session cookies
- int $ret_as: Whether to return cookies as objects of Zend_Http_Cookie or as strings
- int $now: Override the current time when checking for expiry time

_flattenCookiesArray (line 314)

Helper function to recursivly flatten an array. Shoud be used when exporting the cookies array (or parts of it)

- access: protected

array|string _flattenCookiesArray (Zend_Http_Cookie|array $ptr, [int $ret_as = self::COOKIE_OBJECT])

- Zend_Http_Cookie|array $ptr
- int $ret_as: What value to return

_matchDomain (line 353)

Return a subset of the cookies array matching a specific domain

Returned array is actually an array of pointers to items in the $this->cookies array.

- access: protected

array _matchDomain (string $domain)

- string $domain

_matchPath (line 373)

Return a subset of a domain-matching cookies that also match a specified path

Returned array is actually an array of pointers to items in the $passed array.

- access: protected

array _matchPath ( $domains, string $path, array $dom_array)

- array $dom_array
- string $path
- $domains

Class Constants
COOKIE_OBJECT = 0 (line 50)

Return cookie(s) as a Zend_Http_Cookie object

COOKIE_STRING_ARRAY = 1 (line 56)

Return cookie(s) as a string (suitable for sending in an HTTP request)

COOKIE_STRING_CONCAT = 2 (line 62)

Return all cookies as one long string (suitable for sending in an HTTP request)

Documentation generated on Sun, 29 Oct 2006 21:27:53 -0600 by phpDocumentor 1.3.0RC6