2
I’m having trouble saving and reading cookies from a remote site I’m opening with Curl:
$cr = curl_init($this->_URL);
curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cr, CURLOPT_USERAGENT, $useragent );
curl_setopt($cr, CURLOPT_COOKIEFILE, 'cookie.txt');
$html = curl_exec($cr);
curl_close($cr);
I’ve tried to COOKIEJAR
etc, but it doesn’t work!
The site I am opening in Curl, saves cookies when we click on a certain value, this cookie is later read by another file of the site, tested with the proxy of the Glype project, and works perfectly, it saves the cookie, even if I open the site by my cURL
and accessing the file that reads the cookies by the glype proxy that is on the same server, it finds the cookies, but my Curl does not think!
How I save and later read cookies from a remote site using Curl?
According to this topic (http://stackoverflow.com/questions/19295586/why-php-curl-does-not-save-cookie-in-my-cookiefile) You need to use the absolute path to save a cookie.
curl_setopt ($ch, CURLOPT_COOKIEJAR, realpath($cookie_file) );
– Rafael Withoeft
already tried to capture by header?
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_getinfo($ch, CURLINFO_HTTP_CODE);
– Guilherme Lautert
I tried yes, but it doesn’t work! I don’t know what can be wrong.
– Cassiano José