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 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).

Located in /Zend/Http/CookieJar.php (line 51)


	
			
Class Constant Summary
Variable Summary
 array $cookies
Method Summary
 static Zend_Http_CookieJar fromResponse (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)
 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 88)

Array storing cookies

Cookies are stored according to domain and path: $cookies

    • / - cookie1 - cookie2
      • / - alsocookie

      • access: protected
      Methods
      static fromResponse (line 336)

      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 fromResponse (Zend_Http_Response $response,  $ref_uri, Zend_Uri_Http|string $uri)
      Constructor __construct (line 94)

      Construct a new CookieJar object

      • access: public
      Zend_Http_CookieJar __construct ()
      addCookie (line 104)

      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)
      addCookiesFromResponse (line 128)

      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)
      getAllCookies (line 151)

      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 205)

      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 168)

      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 250)

      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])
      _matchDomain (line 289)

      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 309)

      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 57)

      Return cookie(s) as a Zend_Http_Cookie object

      COOKIE_STRING_ARRAY = 1 (line 63)

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

      COOKIE_STRING_CONCAT = 2 (line 69)

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

      Documentation generated on Thu, 18 Jan 2007 09:52:35 -0800 by phpDocumentor 1.3.1