public function addCookie($name, $value)
    {
        if (!empty($this->cookieJar)) {
            $this->cookieJar->store(
                array('name' => $name, 'value' => $value), $this->url
            );

        } else {
            $cookie = $name . '=' . $value;
            if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) {
                throw new HTTP_Request2_LogicException(
                    "Invalid cookie: '{$cookie}'",
                    HTTP_Request2_Exception::INVALID_ARGUMENT
                );
            }
            $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; ';
            $this->setHeader('cookie', $cookies . $cookie);
        }

        return $this;
    }
public function addCookie($name, $value)
    {
        if (!empty($this->cookieJar)) {
            $this->cookieJar->store(
                array('name' => $name, 'value' => $value), $this->url
            );

        } else {
            $cookie = $name . '=' . $value;
            if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) {
                throw new HTTP_Request2_LogicException(
                    "Invalid cookie: '{$cookie}'",
                    HTTP_Request2_Exception::INVALID_ARGUMENT
                );
            }
            $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; ';
            $this->setHeader('cookie', $cookies . $cookie);
        }

        return $this;
    }
public function addCookie ( $ name , $ value ) { if ( ! empty ( $ this -> cookieJar ) ) { $ this -> cookieJar -> store ( array ( 'name' => $ name , 'value' => $ value ) , $ this -> url ) ; } else { $ cookie = $ name . '=' . $ value ; if ( preg_match ( self :: REGEXP_INVALID_COOKIE , $ cookie ) ) { throw new HTTP_Request2_LogicException ( "Invalid cookie: '{$cookie}'" , HTTP_Request2_Exception :: INVALID_ARGUMENT ) ; } $ cookies = empty ( $ this -> headers [ 'cookie' ] ) ? '' : $ this -> headers [ 'cookie' ] . '; ' ; $ this -> setHeader ( 'cookie' , $ cookies . $ cookie ) ; } return $ this ; }
Adds a cookie to the request

If the request does not have a CookieJar object set, this method simply
appends a cookie to "Cookie:" header.

If a CookieJar object is available, the cookie is stored in that object.
Data from request URL will be used for setting its 'domain' and 'path'
parameters, 'expires' and 'secure' will be set to null and false,
respectively. If you need further control, use CookieJar's methods.

@param string $name  cookie name
@param string $value cookie value

@return   HTTP_Request2
@throws   HTTP_Request2_LogicException
@see      setCookieJar()
Adds a cookie to the request