mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-02 05:36:36 +00:00
Add setCookieString method on Curl.php
Add setCookieString method to parse the string cookies and call setCookie method.
This commit is contained in:
+20
-1
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user