I've tried using CURL functions to simulate login form and everything work except setting cookies!
I stripped the code down to its simplest form (where $post_arr is an array holding username, password and action evoked by submit button):
if (!$curl2 = curl_init()) return "Bad connection!";
curl_setopt($curl2, CURLOPT_POST, true);
curl_setopt ($curl2, CURLOPT_HEADER,1);
curl_setopt($curl2, CURLOPT_POSTFIELDS,$post_arr);
curl_setopt($curl2, CURLOPT_URL, $url;
curl_setopt($curl2, CURLOPT_COOKIE, "user=username");
$output2 = curl_exec($curl2);
curl_close($curl2);
echo $output2;
This script does everything right, except the cookie doesn't get set, period!
I also tried CURLOPT_COOKIEJAR in the previous script (it writes to the file "cookies.txt" correctly) and then including CURLOPT_COOKIEFILE , "cookies.txt" in the next script - just doesn't work - no cookies are set.
I'm really stuck - PLEASE HELP!
CURL and COOKIES
Moderator: General Moderators