cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Help with cookies & cURL

From: Colleen R. Dick <platypus_at_proaxis.com>
Date: Sun, 27 Nov 2005 12:47:25 -0800

I have been doing a little dinking with cookies and CURL myself so I
offer the following:

As I understand it, the cookieJar option is where you put cookies that
you want to suck up from a site. In otherwords the cookies the site
sends you. The cookieFile what you call the same file for sending back
cookies previously collected in cookieJar
I don't think you want both in the first call because before you do
anything cookiejar same thing as cookiefile are both empty.
 
I reckon the site checks for cookies enabled by setting a specific one
first time and seeing if it received it back. If you are sucking the
cookie up with your curl script and not sending it back it might think
cookies are disabled. I think curl tells site that cookies are enabled
by sending it a cookie it is expecting, in other words.

This is just me saying what I think it does or should do logically and
what I've seen curl do, and what I know about how cookies work.

On Sun, 2005-11-27 at 18:54 +1300, AtomixNetwork Internet Services
wrote:
> Hi there,
>
> I am currently using this script:
>
> **********************************************
> <?php
> $cookie_file_path = "/home/letsgo/cookies/trademe";
> $LOGINURL = "http://www.trademe.co.nz/structure/login.asp";
> $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
> rv:1.4 ) Gecko/20030624 Netscape/7.1 (ax)";
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL,$LOGINURL);
> curl_setopt($ch, CURLOPT_USERAGENT, $agent);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
> curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
> $result = curl_exec ($ch);
> curl_close ($ch);
>
> $LOGINURL = "http://www.trademe.co.nz/structure/login.asp";
> $POSTFIELDS =
> 'url=&test_auto=&email=my-email_at_email.com&password=uhh';
> $referer = "http://www.trademe.co.nz/structure/login.asp";
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL,$LOGINURL);
> curl_setopt($ch, CURLOPT_USERAGENT, $agent);
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_REFERER, $referer);
> curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
> curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
> $result = curl_exec ($ch);
> curl_close ($ch);
> print $result;
>
> ?>
>
> *******************************************
>
> But it seems like the site checks to see if the browser has cookies
> enabled as it says this on the site:
>
> Your browser does not have cookies enabled. Trade Me may not function
> properly without cookies turned on.
>
> Is there a way to make cURL tell the site that it has cookies enabled?
>
> Thank you!
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-11-28