PHP How to execute an HTTP cookie request and store the result in a string

I would like to execute an http request and pass all the cookies received by the current script (in particular, the sessions defining cookies) for this request. Then I would like to save the result in a string for further manipulations. What is the best way to do this in PHP?

+5
source share
1 answer

cURL? is a simple and supprot cookie.

Edit 19.1 - Here is an example

$ ch = curl_init ();
curl_setopt ($ ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');

$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

CURLOPT_COOKIEJAR - , cURL cookie, , CURLOPT_COOKIEFILE - cURL ( , cookie).

- cookie ( CURLOPT_HEADER "1" - $output) cookie CURLOPT_COOKIE ( cookie foo = bar; bar = foo; ')

. libcurl php.ini

+6

All Articles