API Documentation

Http/CookieJar.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Http
subpackage
CookieJar
version
$Id: CookieJar.php 20096 2010-01-06 02:05:09Z bkarwin $
Classes
Zend_Http_CookieJar

Description

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Zend_Http_CookieJar

Implements
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
link
for some specs.
package
Zend_Http
subpackage
CookieJar
Constants
COOKIE_OBJECT
COOKIE_STRING_ARRAY
COOKIE_STRING_CONCAT
Properties
$cookies
$_rawCookies
Methods
__construct
addCookie
addCookiesFromResponse
getAllCookies
getMatchingCookies
getCookie
_flattenCookiesArray
_matchDomain
_matchPath
fromResponse
count
getIterator
isEmpty
reset

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

Constants

COOKIE_OBJECT

 COOKIE_OBJECT = '0'

Return cookie(s) as a Zend_Http_Cookie object

Details

value
0

COOKIE_STRING_ARRAY

 COOKIE_STRING_ARRAY = '1'

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

Details

value
1

COOKIE_STRING_CONCAT

 COOKIE_STRING_CONCAT = '2'

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

Details

value
2

Properties

$_rawCookies

array $_rawCookies = 'array'

The Zend_Http_Cookie array

Details

$_rawCookies
array
visibility
protected
default
array
final
false
static
false

$cookies

array $cookies = 'array'

Array storing cookies

Cookies are stored according to domain and path: $cookies + www.mydomain.com + / - cookie1 - cookie2 + /somepath - othercookie + www.otherdomain.net + / - alsocookie

Details

$cookies
array
visibility
protected
default
array
final
false
static
false

Methods

__construct

__construct( ) :

Construct a new CookieJar object

Details
visibility
public
final
false
static
false

_flattenCookiesArray

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

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

Arguments
$ptr
Zend_Http_Cookiearray
$ret_as
int
What value to return
Output
array|string
Details
visibility
protected
final
false
static
false

_matchDomain

_matchDomain( string $domain ) : array

Return a subset of the cookies array matching a specific domain

Arguments
$domain
string
Output
array
Details
visibility
protected
final
false
static
false

_matchPath

_matchPath(  $domains, string $path ) : array

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

Arguments
$domains
$path
string
Output
array
Details
visibility
protected
final
false
static
false

addCookie

addCookie( Zend_Http_Cookie|string $cookie, Zend_Uri_Http|string $ref_uri = null ) :

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.

Arguments
$cookie
Zend_Http_Cookiestring
$ref_uri
Zend_Uri_Httpstring
Optional reference URI (for domain, path, secure)
Details
visibility
public
final
false
static
false

addCookiesFromResponse

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

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

Arguments
$response
Zend_Http_Response
$ref_uri
Zend_Uri_Httpstring
Requested URI
Details
visibility
public
final
false
static
false

count

count( ) : int

Required by Countable interface

Output
int
Details
visibility
public
final
false
static
false

fromResponse

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.

Arguments
$response
Zend_Http_Response
HTTP Response object
$ref_uri
Details
visibility
public
final
false
static
true
todo
Add the $uri functionality.

getAllCookies

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

Get all cookies in the cookie jar as an array

Arguments
$ret_as
int
Whether to return cookies as objects of Zend_Http_Cookie or as strings
Output
array|string
Details
visibility
public
final
false
static
false

getCookie

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

Get a specific cookie according to a URI and name

Arguments
$uri
Zend_Uri_Httpstring
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
Output
Zend_Http_Cookie|string
Details
visibility
public
final
false
static
false

getIterator

getIterator( ) : ArrayIterator

Required by IteratorAggregate interface

Output
ArrayIterator
Details
visibility
public
final
false
static
false

getMatchingCookies

getMatchingCookies( string|Zend_Uri_Http $uri, boolean $matchSessionCookies = true, int $ret_as = self, 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.

Arguments
$uri
stringZend_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
Output
array|string
Details
visibility
public
final
false
static
false

isEmpty

isEmpty( ) : bool

Tells if the jar is empty of any cookie

Output
bool
Details
visibility
public
final
false
static
false

reset

reset( ) : Zend_Http_CookieJar

Empties the cookieJar of any cookie

Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.