src/Zend/Http/CookieJar.php
public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT)
    {
        if (is_string($uri)) {
            $uri = Zend_Uri::factory($uri);
        }

        if (! $uri instanceof Zend_Uri_Http) {

            throw new Zend_Http_Exception('Invalid URI specified');
        }

        // Get correct cookie path
        $path = $uri->getPath();
        $path = substr($path, 0, strrpos($path, '/'));
        if (! $path) $path = '/';

        if (isset($this->cookies[$uri->getHost()][$path][$cookie_name])) {
            $cookie = $this->cookies[$uri->getHost()][$path][$cookie_name];

            switch ($ret_as) {
                case self::COOKIE_OBJECT:
                    return $cookie;
                    break;

                case self::COOKIE_STRING_CONCAT_STRICT:
                    return rtrim(trim($cookie->__toString()), ';');
                    break;

                case self::COOKIE_STRING_ARRAY:
                case self::COOKIE_STRING_CONCAT:
                    return $cookie->__toString();
                    break;

                default:

                    throw new Zend_Http_Exception("Invalid value passed for \$ret_as: {$ret_as}");
                    break;
            }
        } else {
            return false;
        }
    }
public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT)
    {
        if (is_string($uri)) {
            $uri = Zend_Uri::factory($uri);
        }

        if (! $uri instanceof Zend_Uri_Http) {

            throw new Zend_Http_Exception('Invalid URI specified');
        }

        // Get correct cookie path
        $path = $uri->getPath();
        $path = substr($path, 0, strrpos($path, '/'));
        if (! $path) $path = '/';

        if (isset($this->cookies[$uri->getHost()][$path][$cookie_name])) {
            $cookie = $this->cookies[$uri->getHost()][$path][$cookie_name];

            switch ($ret_as) {
                case self::COOKIE_OBJECT:
                    return $cookie;
                    break;

                case self::COOKIE_STRING_CONCAT_STRICT:
                    return rtrim(trim($cookie->__toString()), ';');
                    break;

                case self::COOKIE_STRING_ARRAY:
                case self::COOKIE_STRING_CONCAT:
                    return $cookie->__toString();
                    break;

                default:

                    throw new Zend_Http_Exception("Invalid value passed for \$ret_as: {$ret_as}");
                    break;
            }
        } else {
            return false;
        }
    }
public function getCookie ( $ uri , $ cookie_name , $ ret_as = self :: COOKIE_OBJECT ) { if ( is_string ( $ uri ) ) { $ uri = Zend_Uri :: factory ( $ uri ) ; } if ( ! $ uri instanceof Zend_Uri_Http ) { throw new Zend_Http_Exception ( 'Invalid URI specified' ) ; } // Get correct cookie path $ path = $ uri -> getPath ( ) ; $ path = substr ( $ path , 0 , strrpos ( $ path , '/' ) ) ; if ( ! $ path ) $ path = '/' ; if ( isset ( $ this -> cookies [ $ uri -> getHost ( ) ] [ $ path ] [ $ cookie_name ] ) ) { $ cookie = $ this -> cookies [ $ uri -> getHost ( ) ] [ $ path ] [ $ cookie_name ] ; switch ( $ ret_as ) { case self :: COOKIE_OBJECT : return $ cookie ; break ; case self :: COOKIE_STRING_CONCAT_STRICT : return rtrim ( trim ( $ cookie -> __toString ( ) ) , ';' ) ; break ; case self :: COOKIE_STRING_ARRAY : case self :: COOKIE_STRING_CONCAT : return $ cookie -> __toString ( ) ; break ; default : throw new Zend_Http_Exception ( "Invalid value passed for \$ret_as: {$ret_as}" ) ; break ; } } else { return false ; } }
Get a specific cookie according to a URI and name

@param Zend_Uri_Http|string $uri The uri (domain and path) to match
@param string $cookie_name The cookie's name
@param int $ret_as Whether to return cookies as objects of Zend_Http_Cookie or as strings
@return Zend_Http_Cookie|string
Get a specific cookie according to a URI and name