curl-and-php
RE: Retrieving cookies
Date: Sat, 24 Apr 2004 16:41:00 -0400 (EDT)
Adam> I need to retrieve a cookie that is set by
Adam> the page after I do a Curl POST submit to it.
Mind if is why?
Maybe someone can suggest an alternate course of action if you can't do it directly using cURL.
Adam> So I messed around with this a bit and with
Adam> the intention that any cookie information
Adam> would be written to the filename
Adam> (/tmp/my_cookies.txt) I sent CURLOPT_COOKIEJAR
Adam> to so I then could read the information out of
Adam> the file. However, the file was never written.
Does your PHP script have write permissions for that directory and file?
Have you tried writing to a file located relative to the script?
(eg. curl_setopt($ch2, CURLOPT_COOKIEFILE, "my_cookies.txt");
Dan O.
--- On Thu 04/22, Adam Bodnar wrote:
Subject: Retrieving cookies
I'm very new to Curl, but figuring it out pretty quickly.
A problem I'm running into is that I need to retrieve a cookie that is set by the page after I do a Curl POST submit to it.
Now I've read thru all the documentation and all I found was mention of CURLOPT_COOKIEFILE and then some examples with CURLOPT_COOKIEJAR. Now the former seems to be entirely related to sending a file with the cookie information you want to pass to a Curl session and the latter seems to be something where you can store the cookies(despite the lack of documentation on this on the PHP site).
I would prefer that I could set a variable to the cookie(s), but from a bug I read on the PHP site, it seems this is not possible yet.
So I messed around with this a bit and with the intention that any
cookie information would be written to the filename(/tmp/my_cookies.txt) I sent CURLOPT_COOKIEJAR to so I then
could read the information out of the file. However, the file was never written.
curl_setopt($ch2, CURLOPT_COOKIEJAR, "/tmp/my_cookies.txt");
curl_setopt($ch2, CURLOPT_COOKIEFILE, "/tmp/my_cookies.txt");
It seems the only way I can grab the cookies that are set by the page
would be write a regular expression to parse the header information
that is returned by the curl_exec cmd.
So in all,
1) Is there no way to get the cookie information that is set by a curl session into a variable?
2) If 1 is not possible, can you write it to a file? If so, then what
am I doing wrong.
3) If 1 and 2 aren't possible or it makes sense, should I just parse
the header information?
Thanks for the help,
Adam Bodnar
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
Received on 2004-04-24