src/Zend/Http/CookieJar.php
public function getMatchingCookies($uri, $matchSessionCookies = true,
        $ret_as = self::COOKIE_OBJECT, $now = null)
    {
        if (is_string($uri)) $uri = Zend_Uri::factory($uri);
        if (! $uri instanceof Zend_Uri_Http) {

            throw new Zend_Http_Exception("Invalid URI string or object passed");
        }

        // First, reduce the array of cookies to only those matching domain and path
        $cookies = $this->_matchDomain($uri->getHost());
        $cookies = $this->_matchPath($cookies, $uri->getPath());
        $cookies = $this->_flattenCookiesArray($cookies, self::COOKIE_OBJECT);

        // Next, run Cookie->match on all cookies to check secure, time and session mathcing
        $ret = array();
        foreach ($cookies as $cookie)
            if ($cookie->match($uri, $matchSessionCookies, $now))
                $ret[] = $cookie;

        // Now, use self::_flattenCookiesArray again - only to convert to the return format ;)
        $ret = $this->_flattenCookiesArray($ret, $ret_as);
        if($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
            $ret = rtrim(trim($ret), ';');
        }

        return $ret;
    }
public function getMatchingCookies($uri, $matchSessionCookies = true,
        $ret_as = self::COOKIE_OBJECT, $now = null)
    {
        if (is_string($uri)) $uri = Zend_Uri::factory($uri);
        if (! $uri instanceof Zend_Uri_Http) {

            throw new Zend_Http_Exception("Invalid URI string or object passed");
        }

        // First, reduce the array of cookies to only those matching domain and path
        $cookies = $this->_matchDomain($uri->getHost());
        $cookies = $this->_matchPath($cookies, $uri->getPath());
        $cookies = $this->_flattenCookiesArray($cookies, self::COOKIE_OBJECT);

        // Next, run Cookie->match on all cookies to check secure, time and session mathcing
        $ret = array();
        foreach ($cookies as $cookie)
            if ($cookie->match($uri, $matchSessionCookies, $now))
                $ret[] = $cookie;

        // Now, use self::_flattenCookiesArray again - only to convert to the return format ;)
        $ret = $this->_flattenCookiesArray($ret, $ret_as);
        if($ret_as == self::COOKIE_STRING_CONCAT_STRICT) {
            $ret = rtrim(trim($ret), ';');
        }

        return $ret;
    }
public function getMatchingCookies ( $ uri , $ matchSessionCookies = true , $ ret_as = self :: COOKIE_OBJECT , $ now = null ) { if ( is_string ( $ uri ) ) $ uri = Zend_Uri :: factory ( $ uri ) ; if ( ! $ uri instanceof Zend_Uri_Http ) { throw new Zend_Http_Exception ( "Invalid URI string or object passed" ) ; } // First, reduce the array of cookies to only those matching domain and path $ cookies = $ this -> _matchDomain ( $ uri -> getHost ( ) ) ; $ cookies = $ this -> _matchPath ( $ cookies , $ uri -> getPath ( ) ) ; $ cookies = $ this -> _flattenCookiesArray ( $ cookies , self :: COOKIE_OBJECT ) ; // Next, run Cookie->match on all cookies to check secure, time and session mathcing $ ret = array ( ) ; foreach ( $ cookies as $ cookie ) if ( $ cookie -> match ( $ uri , $ matchSessionCookies , $ now ) ) $ ret [ ] = $ cookie ; // Now, use self::_flattenCookiesArray again - only to convert to the return format ;) $ ret = $ this -> _flattenCookiesArray ( $ ret , $ ret_as ) ; if ( $ ret_as == self :: COOKIE_STRING_CONCAT_STRICT ) { $ ret = rtrim ( trim ( $ ret ) , ';' ) ; } return $ ret ; }
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.

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