I need to execute cURL methods that equals the below one in PHP because I wanna persist cookies when it redirects.
curl -b test.cookie -L http://website.com
I tried to set some options in curl_setopt() as below, but I couldn't get the answer.
<?php
$ch = curl_init();
curl_setopt_array($ch, array(
// :
// Some lines are hidden here.
// :
CURLOPT_RETURNTRANSFER => true,
CURLOPT_COOKIESESSION => true,
CURLOPT_COOKIEFILE => 'test.txt',
CURLOPT_COOKIEJAR => 'test.txt',
));
$html = curl_exec($ch);
$http = curl_getinfo($ch);
curl_close($ch);
Does anyone have good ideas?