Add setCookieString method on Curl.php

Add setCookieString method to parse the string cookies and call setCookie method.
This commit is contained in:
Chengke Sun
2016-05-11 14:12:10 +08:00
parent 1e100063a3
commit 1fbf55d15f
+20 -1
View File
@@ -697,7 +697,26 @@ class Curl
{
$this->setOpt(CURLOPT_CONNECTTIMEOUT, $seconds);
}
/**
* Set Cookie String
*
* @access public
* @param $string
*/
public function setCookieString($string)
{
if(preg_match_all('/\s*([^;=]+)=([^;]+)/i',$string,$matches) > 0){
if(isset($matches[1]) && isset($matches[2])){
if(count($matches[1]) == count($matches[2])){
foreach ($matches[1] as $handle => $key) {
$this->setCookie($key, $matches[2][$handle]);
}
}
}
}
}
/**
* Set Cookie File
*