curl-and-php
RE: cookies problem
Date: Wed, 8 Jul 2009 08:52:14 +0800
Hi Richard,
The documentation states the opposite though, and personally I couldn't
really tell them apart at first glance - they should have name it something
like CURLOPT_COOKIELOADFROM and CURLOPT_COOKIESAVETO.
http://sg.php.net/manual/en/function.curl-setopt.php
CURLOPT_COOKIEFILE
The name of the file containing the cookie data. The cookie file can be in
Netscape format, or just plain HTTP-style headers dumped into a file.
CURLOPT_COOKIEJAR
The name of a file to save all internal cookies to when the connection
closes.
With regards,
Liu Shan Shui
me_at_lx.sg
"Life would be much easier if I had the source code." - Anonymous
-----Original Message-----
From: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] On Behalf Of Richard Lynch
Sent: Wednesday, July 08, 2009 2:13 AM
To: curl with PHP
Subject: Re: cookies problem
You also need CURLOPT_COOKIEFILE, $cookie);
COOKIEJAR is where it *gets* the cookies.
COOKIEFILE is where it will *store* the cookies.
Usually you want them the same, but imagine a case where you only want
to read the old cookies, and never store them...
On Tue, July 7, 2009 8:29 am, cata keat wrote:
> Hi ! I am new here and also to curl .
> One question :
> why the curl does not save the cookis in the file :
> <?php
> /*
> This script is an example of using curl in php to log into on one page
> and
> then get another page passing all cookies from the first page along
> with you.
> If this script was a bit more advanced it might trick the server into
> thinking its netscape and even pass a fake referer, yo look like it
> surfed
> from a local page.
> */
> $cookie="cookie.txt";
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie);
> curl_setopt($ch, CURLOPT_URL,"https://accounts.craigslist.org/login");
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch,
>
CURLOPT_POSTFIELDS,inputEmailHandle=arsulescucata_at_yahoo.com&inputPassword=pw
dxxx);
> ob_start(); // prevent any output
> curl_exec ($ch); // execute the curl command
>
> ob_end_clean(); // stop preventing output
> curl_close ($ch);
> unset($ch);
> $cookie_contents = file_get_contents($cookie);
> echo $cookie_contents;
> ?>
> Bests regards!
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
-- Some people ask for gifts here. I just want you to buy an Indie CD for yourself: http://cdbaby.com/search/from/lynch _______________________________________________ http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php _______________________________________________ http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-phpReceived on 2009-07-08