Skip to content

Commit 7b4d4da

Browse files
author
Ich
committed
implementing get cookie functionality
1 parent 473f080 commit 7b4d4da

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Curl/Curl.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ public function head($url, $data = array())
401401
*/
402402
public function headerCallback($ch, $header)
403403
{
404+
if (preg_match('/^Set-Cookie:\s*([^=]+)=([^;]+)/mi', $header, $cookie) == 1) {
405+
$this->cookies[$cookie[1]] = $cookie[2];
406+
}
404407
$this->rawResponseHeaders .= $header;
405408
return strlen($header);
406409
}
@@ -539,6 +542,16 @@ public function setCookie($key, $value)
539542
$this->setOpt(CURLOPT_COOKIE, str_replace(' ', '%20', urldecode(http_build_query($this->cookies, '', '; '))));
540543
}
541544

545+
/**
546+
* get Cookie
547+
*
548+
* @access public
549+
* @param $key
550+
*/
551+
public function getCookie($key) {
552+
return $this->cookies[$key];
553+
}
554+
542555
/**
543556
* Set Port
544557
*

0 commit comments

Comments
 (0)