Search This Blog

Loading...

Friday, December 16, 2011

How to let Curl use same cookie as the browser from PHP

By default, libcurl always stores and loads all cookies, independent if they are session cookies or not.
However you may need to set cookies directly, which can be done using:
curl_setopt($ch, CURLOPT_COOKIE, 'foo=bar');
Which is the same as the Set-Cookie HTTP header. Check you're not using curl_setopt($ch, CURLOPT_COOKIESESSION, true) as this will make libcurl ignore some cookies.
Or in linux console, using the following command:
curl -v --cookie "cookieName=abc=adf;123" http://abc.com/

0 comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails