mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-28 19:20:56 +00:00
Simplify Curl::setCookieString
This commit is contained in:
@@ -222,6 +222,7 @@ Curl::setConnectTimeout($seconds)
|
||||
Curl::setCookie($key, $value)
|
||||
Curl::setCookieFile($cookie_file)
|
||||
Curl::setCookieJar($cookie_jar)
|
||||
Curl::setCookieString($string)
|
||||
Curl::setDefaultJsonDecoder()
|
||||
Curl::setDefaultTimeout()
|
||||
Curl::setDefaultUserAgent()
|
||||
|
||||
+1
-9
@@ -721,15 +721,7 @@ class Curl
|
||||
*/
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->setOpt(CURLOPT_COOKIE, $string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user