I would like to perform an http request and pass all cookies received by the current script (in particular session identifying cookies) to this request. Then I would like to save the result in a string for further manipulation. What is the best way to do this in PHP ?
Share
cURL ? – it is simple and supprot cookies .
Edit 19.1 – Here is example
CURLOPT_COOKIEJAR is file where cURL put cookies sent from server and CURLOPT_COOKIEFILE is file with cookies for sending by cURL ( setting it to same one will make it cookies file ).
Another option is manually read cookies from result ( set CURLOPT_HEADER to ‘1’ – it will put result header into $output ) and send cookies via CURLOPT_COOKIE ( set it to list of cookies in format ‘foo=bar;bar=foo;’ )
Note – libcurl must be enabled in php.ini