curl-and-php
Re: cookies problem
Date: Tue, 7 Jul 2009 13:13:19 -0500 (CDT)
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=pwdxxx);
> 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-phpReceived on 2009-07-07