Greetings All !
I've got a piece of code that has been working fine on a particular site I
own for a few weeks now.
The piece in question basically is a loop. Basically, we take five similar
websites and process through each of them in this loop.
Curl is used to make a request to pull up the site's login page. At this
point, the site tries to set a cookie in a browser, so curl is set to
capture that cookie a la setopt_cookiejar. Curl then makes a second
request, passing login information to the form-processing script on the
destination site. The destination site apparently looks to see if that
cookie's been set. The second request then gives us some output we don't
really need... but this completes the log-in sequence.
After this, we make some other requests to pull in data.
When those are complete, the loop starts over with site #2, and so on.
Now, this has been working fine on MY site for a few weeks.
Late last week, I moved copy of this script over to somebody ELSE'S site on
a different server. Here, the script processes through ALL of the websites
we ask it to log into EXCEPT one!! My troubleshooting has determined that
the cookie file is NOT getting written to! And I cannot understand WHY.
I tried cutting-and-pasting the large chunk of code from my site into this
other site's copy of the script.... just in case I somehow deleted a
character or something earlier.... but the problem remains the same!
I don't get it. What could possibly be keeping us from writing that cookie
The loop of code starts something like this.
// manually create the cookie file with a unique identifier
echo "mycookiefile= $mycookiefile <BR>";
$fp = fopen("$mycookiefile","w") or die("<BR><B>Unable to
open cookie file $mycookiefile for write!<BR>");
// I stuck this in in one of my troubleshooting attempts,
thinking it was a file permissions problem
$fh = fopen("/home/davez_curl_log.txt",'w') or die("Unable
to open davez_curl_log.txt file<BR>");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER,1); // return header with
curl_setopt($ch, CURLOPT_COOKIEJAR, "$mycookiefile");
curl_setopt($ch, CURLOPT_STDERR, $fh);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
// here I shoved a few things that I thought might help me
debug the problem.
The cookie file gets created and chmod'ed properly. But nothing ever gets
written to it.
But remember, this code works with "four out of five websites surveyed".
Any ideas anyone? This one has had me stumped for days.
-= Dave =-
Received on 2004-02-24