how can i set cookie in curl

Posted by Sushant Panigrahi on Stack Overflow See other posts from Stack Overflow or by Sushant Panigrahi
Published on 2010-04-01T11:48:40Z Indexed on 2010/04/01 11:53 UTC
Read the original article Hit count: 470

Filed under:
|

i am fetching somesite page..

but it display nothing and url address change.

example i have typed

http://localhost/sushant/EXAMPLE_ROUGH/curl.php

in curl page my coding is=

$fp = fopen("cookie.txt", "w");

fclose($fp);

$agent= 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0';

$ch = curl_init();

curl_setopt($ch, CURLOPT_USERAGENT, $agent); // 2. set the options, including the url

curl_setopt($ch, CURLOPT_URL, "http://www.fnacspectacles.com/place-spectacle/manifestation/Grand-spectacle-LE-ROI-LION-ROI4.htm");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); // 3. execute and fetch the resulting HTML output

if(curl_exec($ch) === false)

{

echo 'Curl error: ' . curl_error($ch);

}

else

echo $output = curl_exec($ch);

// 4. free up the curl handle
curl_close($ch);
?>

but it canege url like this..

http://localhost/aide.do?sht=_aide_cookies_

object not found.

how can solve these problem help me

© Stack Overflow or respective owner

Related posts about curl

Related posts about php