Doctrine\OrientDB\Binding\Client\Http\CurlClientResponse::getCookies PHP Method

getCookies() public method

Returns the cookies set in the current response.
public getCookies ( ) : array
return array
    public function getCookies()
    {
        $jar = array();
        $headers = $this->getRawHeaders();
        if (preg_match_all('/Set-Cookie: (.*)\\b/', $headers, $cookies)) {
            foreach ($cookies[1] as $cookie) {
                list($cookie, ) = explode(';', $cookie, 2);
                list($name, $value) = explode('=', $cookie, 2);
                $jar[$name] = $value;
            }
        }
        return $jar;
    }

Usage Example

Example #1
0
 /**
  * Executes a Curl.
  *
  * @param  String $method
  * @param  String $location
  *
  * @return CurlClientResponse
  * @throws ConnectionFailedException
  */
 public function execute($method, $location)
 {
     curl_setopt_array($this->curl, [CURLOPT_URL => $location, CURLOPT_COOKIE => $this->getRequestCookies(), CURLOPT_CUSTOMREQUEST => $method]);
     if (!($response = curl_exec($this->curl))) {
         $err = curl_error($this->curl);
         $msg = sprintf("unable to communicate with server at '%s'; %s", $location, $err);
         $this->restart();
         throw new ConnectionFailedException($msg);
     }
     $response = new CurlClientResponse($response);
     $this->cookies = array_merge($this->cookies, $response->getCookies());
     if ($this->restart === true) {
         $this->restart();
     }
     return $response;
 }