View Full Version : cURL and handleing cookies

05-12-2009, 01:10 PM
So what I want to do is create a cURL snippplet that will POST data somewhere , get the cookies from the response, sends them to a txt file to be used to call upon another URL.

Then I want it to grab the value of one certain cookie and echo it. (Preferably not from the txt file , but from the set cookie headers.

So for example, if it sets multiple cookies. (like Set-Cookie:Auth1=abcdefg;Auth2=hijk; ) , I just want the value of the Auth2 cookie that was set in the original process.

05-12-2009, 02:39 PM

The PHP documentation for CURL is quite poor, however the differences between the PHP front-end and the C source code for the module are minimal.

So if you are conversant with C, you might like to have a look at this file: http://curl.haxx.se/dev/COOKIES

Sorry I can't be more specific, I haven't ever needed to do what you're trying to do.

EDIT: Perhaps the CURLINFO_HEADER_OUT option with curl_getinfo (http://uk2.php.net/manual/en/function.curl-getinfo.php) might help you. I don't know though.

EDIT 2: This might help you: http://uk3.php.net/manual/en/reserved.variables.httpresponseheader.php Or this: http://uk3.php.net/manual/en/function.get-headers.php