Setting cookie to use cURL

I am retrieving another page using cURL, and if I do not have a specific cookie, I cannot see the contents of the page. The cookie name seepageand value must be set to 1 to view the contents of the page.

I would like to load this page using cURL, and this script I have at the moment:

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://www.pixhost.org/images/531/1245992_untitled-2.jpg');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_COOKIE, 'tmpfile.tmp');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'tmpfile.tmp');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'tmpfile.tmp');
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

$result = curl_exec($ch);

print_r($result);

?>

However, $ result is an empty variable for which I can confirm with if(empty($result)). How would I set cURL to use a cookie with a name seepagewith a cookie value 1?

Thanks.

+5
source share
1 answer

The value of the cookie is "seepage = 1":

curl_setopt($ch, CURLOPT_COOKIE, 'seepage=1');

CURLOPT_COOKIEFILE

+8

All Articles