Class Zend_Http_CookieJar

Description

Implements interfaces:

  • Countable (internal interface)
  • IteratorAggregate (internal interface)

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 /Http/CookieJar.php (line 60)


	
			
Class Constant Summary
Variable Summary
 array $cookies
 array $_rawCookies
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, [Zend_Uri_Http|string $ref_uri = null])
 void addCookiesFromResponse (Zend_Http_Response $response, Zend_Uri_Http|string $ref_uri)
 int count ()
 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])
 ArrayIterator getIterator ()
 array|string getMatchingCookies (string|Zend_Uri_Http $uri, [boolean $matchSessionCookies = true], [int $ret_as = self::COOKIE_OBJECT], [int $now = null])
 bool isEmpty ()
 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 97)

Array storing cookies

Cookies are stored according to domain and path: $cookies

    • / - cookie1 - cookie2
      • / - alsocookie

      • access: protected
      array $_rawCookies = array() (line 104)

      The Zend_Http_Cookie array

      • access: protected
      Methods
      static fromResponse (line 356)

      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.

      • todo: Add the $uri functionality.
      • access: public
      static Zend_Http_CookieJar fromResponse (Zend_Http_Response $response,  $ref_uri, Zend_Uri_Http|string $uri)
      Constructor __construct (line 110)

      Construct a new CookieJar object

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

      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, [Zend_Uri_Http|string $ref_uri = null])
      addCookiesFromResponse (line 146)

      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)
      count (line 368)

      Required by Countable interface

      • access: public
      int count ()

      Implementation of:
      Countable::count
      getAllCookies (line 171)

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

      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
      getIterator (line 378)

      Required by IteratorAggregate interface

      • access: public
      ArrayIterator getIterator ()

      Implementation of:
      IteratorAggregate::getIterator
      getMatchingCookies (line 188)

      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
      isEmpty (line 388)

      Tells if the jar is empty of any cookie

      • access: public
      bool isEmpty ()
      reset (line 398)

      Empties the cookieJar of any cookie

      • access: public
      _flattenCookiesArray (line 269)

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

      Return a subset of the cookies array matching a specific domain

      • access: protected
      array _matchDomain (string $domain)
      • string $domain
      _matchPath (line 326)

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

      • access: protected
      array _matchPath ( $domains, string $path, array $dom_array)
      • array $dom_array
      • string $path
      • $domains
      Class Constants
      COOKIE_OBJECT = 0 (line 66)

      Return cookie(s) as a Zend_Http_Cookie object

      COOKIE_STRING_ARRAY = 1 (line 72)

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

      COOKIE_STRING_CONCAT = 2 (line 78)

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

      Documentation generated on Mon, 21 Jun 2010 15:14:23 -0400 by phpDocumentor 1.4.3