26 #require_once "Zend/Uri.php"; 30 #require_once "Zend/Http/Cookie.php"; 34 #require_once "Zend/Http/Response.php"; 128 public function addCookie($cookie, $ref_uri =
null, $encodeValue =
true)
130 if (is_string($cookie)) {
135 $domain = $cookie->getDomain();
136 $path = $cookie->getPath();
137 if (! isset($this->cookies[$domain])) $this->cookies[$domain] = array();
138 if (! isset($this->cookies[$domain][
$path])) $this->cookies[$domain][
$path] = array();
139 $this->cookies[$domain][
$path][$cookie->getName()] = $cookie;
140 $this->_rawCookies[] = $cookie;
142 #require_once 'Zend/Http/Exception.php'; 143 throw new Zend_Http_Exception(
'Supplient argument is not a valid cookie string or object');
158 #require_once 'Zend/Http/Exception.php'; 163 $cookie_hdrs =
$response->getHeader(
'Set-Cookie');
165 if (is_array($cookie_hdrs)) {
166 foreach ($cookie_hdrs as $cookie) {
167 $this->
addCookie($cookie, $ref_uri, $encodeValue);
169 }
elseif (is_string($cookie_hdrs)) {
170 $this->
addCookie($cookie_hdrs, $ref_uri, $encodeValue);
183 if($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
201 $ret_as = self::COOKIE_OBJECT, $now =
null)
204 if (! $uri instanceof Zend_Uri_Http) {
205 #require_once 'Zend/Http/Exception.php'; 217 if ($cookie->match($uri, $matchSessionCookies, $now))
222 if($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
223 $ret = rtrim(trim($ret),
';');
237 public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT)
239 if (is_string($uri)) {
243 if (! $uri instanceof Zend_Uri_Http) {
244 #require_once 'Zend/Http/Exception.php'; 249 $path = $uri->getPath();
253 if (isset($this->cookies[$uri->getHost()][
$path][$cookie_name])) {
254 $cookie = $this->cookies[$uri->getHost()][
$path][$cookie_name];
262 return rtrim(trim($cookie->__toString()),
';');
267 return $cookie->__toString();
271 #require_once 'Zend/Http/Exception.php'; 289 if (is_array($ptr)) {
291 foreach ($ptr as
$item) {
292 if ($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
293 $postfix_combine = (!is_array(
$item) ?
' ' :
'');
295 }
elseif ($ret_as == self::COOKIE_STRING_CONCAT) {
305 return array($ptr->__toString());
312 return $ptr->__toString();
335 foreach (array_keys($this->cookies) as $cdom) {
337 $ret[$cdom] = $this->cookies[$cdom];
355 foreach ($domains as $dom => $paths_array) {
356 foreach (array_keys($paths_array) as $cpath) {
358 if (! isset($ret[$dom])) {
359 $ret[$dom] = array();
362 $ret[$dom][$cpath] = $paths_array[$cpath];
384 $jar->addCookiesFromResponse(
$response, $ref_uri);
395 return count($this->_rawCookies);
405 return new ArrayIterator($this->_rawCookies);
415 return count($this) == 0;
425 $this->cookies = $this->_rawCookies = array();
elseif(isset( $params[ 'redirect_parent']))
static factory($uri='http', $className=null)
_flattenCookiesArray($ptr, $ret_as=self::COOKIE_OBJECT)
getMatchingCookies($uri, $matchSessionCookies=true, $ret_as=self::COOKIE_OBJECT, $now=null)
static fromString($cookieStr, $refUri=null, $encodeValue=true)
const COOKIE_STRING_CONCAT
getCookie($uri, $cookie_name, $ret_as=self::COOKIE_OBJECT)
const COOKIE_STRING_ARRAY
static matchCookiePath($cookiePath, $path)
_matchPath($domains, $path)
getAllCookies($ret_as=self::COOKIE_OBJECT)
static matchCookieDomain($cookieDomain, $host)
static fromResponse(Zend_Http_Response $response, $ref_uri)
addCookie($cookie, $ref_uri=null, $encodeValue=true)
addCookiesFromResponse($response, $ref_uri, $encodeValue=true)
const COOKIE_STRING_CONCAT_STRICT