Re: cURL & cookies
| From: | Eric Butera | Date: | Tue, 25 Apr 2006 16:50:12 +0000 |
| Subject: | Re: cURL & cookies | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-234712@lists.php.net to get a copy of this message | ||
On 4/25/06, Richard Lynch <ceo@l-i-e.com> wrote:Oh, and here's the REAL
problem:
>
> If you use CURLOPT_HEADER, 1, then, like, for some reason beyond my
> ken, the COOKIEJAR/COOOKIEFILE stuff just plain doesn't get done.
>
> This really sucks if you need *other* headers and want curl to manage
> the Cookies for you, but there it is.
>
> I'm not sure if I remembered to file a bug report on that or not...
>
> If the general conscensus on this list is that CURLOPT_HEADER "on"
> should not negate the use of CURLOPT_COOKIEFILE and/or
> CURLOPT_COOKIEJAR, then we may want to file a bug report...
>
> But I strongly suspect that bug report would most correctly go to
> curl, and not PHP, since I doubt that PHP does anything to screw this
> up -- it's probably all in curl itself, no?
>
> Or maybe me and Peter are the only 2 guys on the planet that think you
> should get to have both...
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> Richard,
On an application I was forced to write, the goal was to create an interface
to another system on another server. I used cURL to grab the pages. Their
system sent three cookies and used tons of redirects to set their session
and validate logins. So basically I ended up with something like this:
define('_COOKIEJAR', '/tmp/cjar_'. session_id());
define('_COOKIEFILE', _COOKIEJAR);
curl_setopt($curl, CURLOPT_COOKIEJAR, _COOKIEJAR);
curl_setopt($curl, CURLOPT_COOKIEFILE, _COOKIEJAR);
curl_setopt($curl, CURLOPT_HEADER, TRUE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
I'm sure this is all wrong, but it was all I could come up with. ;)
I have headers turned on so that I can parse them to get the header redirect
history so that I can track a sort of "browser history." Curl just reported
the original url even though I was three redirects away from what curl
thinks it is.
My point is that I have headers turned on and the cookie jar files get wrote
to /tmp. So am I misunderstanding that you said it is one or the other?
Let me know if I'm wrong, thanks!