I'm brand new to using cURL and I am trying to log into a vBulletin based forum (just like this one).
At this point I can get it to say "Thanks for logging in [username], wait while we redirect you", but once I get to the forums, the script is obviously not logged in anymore.
So it is as if the server OK's the authentication, but once I get to the forums it doesn't know I'm logged in. This leads me to believe it is a cookies problem.
Here is what I have as my code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
$source = "http://forumname.com/forums";
$contents = file_get_contents($source);
echo $contents;
I chmodded my cookie.txt to (777), but they are empty after the script runs.
Any ideas? This has been KILLING me ALL day yesterday and today. I will name my first born after whoever can fix this for me.