Reputation: 67928
I am passing post data to a website, but I have to visit the homepage first before I can navigate to any other parts of the website. So how can I do that? Do I just use a header redirect and then have it execute the rest of the cURL?
Update:
I think this might be better than the solution below: http://coderscult.com/php/php-curl/2008/05/20/php-curl-cookies-example/
Upvotes: 0
Views: 3435
Reputation: 7215
Just run two cURL calls using the same object. So first initialize cURL with the homepage URL, and execute the session:
$curl = curl_init("http://example.com");
curl_exec($curl);
Then using the same object, set a new URL, and execute it with your set parameters:
curl_setopt($curl,CURLOPT_URL,"your_new_url");
curl_setopt($curl,CURLOPT_POSTFIELDS,"var1=value&var2=another_value");
curl_exec($curl);
Upvotes: 3