public function getMatching(Net_URL2 $url, $asString = false)
    {
        $host   = $url->getHost();
        $path   = $url->getPath();
        $secure = 0 == strcasecmp($url->getScheme(), 'https');

        $matched = $ret = array();
        foreach (array_keys($this->cookies) as $domain) {
            if ($this->domainMatch($host, $domain)) {
                foreach (array_keys($this->cookies[$domain]) as $cPath) {
                    if (0 === strpos($path, $cPath)) {
                        foreach ($this->cookies[$domain][$cPath] as $name => $cookie) {
                            if (!$cookie['secure'] || $secure) {
                                $matched[$name][strlen($cookie['path'])] = $cookie;
                            }
                        }
                    }
                }
            }
        }
        foreach ($matched as $cookies) {
            krsort($cookies);
            $ret = array_merge($ret, $cookies);
        }
        if (!$asString) {
            return $ret;
        } else {
            $str = '';
            foreach ($ret as $c) {
                $str .= (empty($str)? '': '; ') . $c['name'] . '=' . $c['value'];
            }
            return $str;
        }
    }
public function getMatching(Net_URL2 $url, $asString = false)
    {
        $host   = $url->getHost();
        $path   = $url->getPath();
        $secure = 0 == strcasecmp($url->getScheme(), 'https');

        $matched = $ret = array();
        foreach (array_keys($this->cookies) as $domain) {
            if ($this->domainMatch($host, $domain)) {
                foreach (array_keys($this->cookies[$domain]) as $cPath) {
                    if (0 === strpos($path, $cPath)) {
                        foreach ($this->cookies[$domain][$cPath] as $name => $cookie) {
                            if (!$cookie['secure'] || $secure) {
                                $matched[$name][strlen($cookie['path'])] = $cookie;
                            }
                        }
                    }
                }
            }
        }
        foreach ($matched as $cookies) {
            krsort($cookies);
            $ret = array_merge($ret, $cookies);
        }
        if (!$asString) {
            return $ret;
        } else {
            $str = '';
            foreach ($ret as $c) {
                $str .= (empty($str)? '': '; ') . $c['name'] . '=' . $c['value'];
            }
            return $str;
        }
    }
public function getMatching ( Net_URL2 $ url , $ asString = false ) { $ host = $ url -> getHost ( ) ; $ path = $ url -> getPath ( ) ; $ secure = 0 == strcasecmp ( $ url -> getScheme ( ) , 'https' ) ; $ matched = $ ret = array ( ) ; foreach ( array_keys ( $ this -> cookies ) as $ domain ) { if ( $ this -> domainMatch ( $ host , $ domain ) ) { foreach ( array_keys ( $ this -> cookies [ $ domain ] ) as $ cPath ) { if ( 0 === strpos ( $ path , $ cPath ) ) { foreach ( $ this -> cookies [ $ domain ] [ $ cPath ] as $ name => $ cookie ) { if ( ! $ cookie [ 'secure' ] || $ secure ) { $ matched [ $ name ] [ strlen ( $ cookie [ 'path' ] ) ] = $ cookie ; } } } } } } foreach ( $ matched as $ cookies ) { krsort ( $ cookies ) ; $ ret = array_merge ( $ ret , $ cookies ) ; } if ( ! $ asString ) { return $ ret ; } else { $ str = '' ; foreach ( $ ret as $ c ) { $ str .= ( empty ( $ str ) ? '' : '; ' ) . $ c [ 'name' ] . '=' . $ c [ 'value' ] ; } return $ str ; } }
Returns all cookies matching a given request URL

The following checks are made:
- cookie domain should match request host
- cookie path should be a prefix for request path
- 'secure' cookies will only be sent for HTTPS requests

@param Net_URL2 $url      Request url
@param bool     $asString Whether to return cookies as string for "Cookie: " header

@return array|string Matching cookies
Returns all cookies matching a given request URL