Re: Curl & cookies

From: Date: Mon, 10 May 2004 02:40:18 +0000
Subject: Re: Curl & cookies
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185770@lists.php.net to get a copy of this message
* Thus wrote Jason Morehouse (jm@netconcepts.com): > Has anyone tried using curl to fetch a web page and cookies? > > <? > $ch = curl_init(); > curl_setopt ($ch, CURLOPT_URL, 'http://www.php.net'); > curl_setopt ($ch, CURLOPT_HEADER, 0); > curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); > curl_setopt ($ch, CURLOPT_COOKIEJAR,'cookie.txt'); > curl_setopt ($ch, CURLOPT_COOKIE,1); > $content = curl_exec ($ch); > curl_close ($ch); > $cookie = file_get_contents('cookie.txt'); > print $cookie; > ?> > > > This works fine, and the cookie gets stored in the cookie.txt file, but it > only ever returns 1 cookie. There should be 2 for php.net. Same with > pretty much any other site. Are there any configuration items I'm missing > for the cookie jar? php's front page will only set one cookie, only in certain conditions will it set other cookies. I have 4 total from php.net: LAST_SEARCH, MYPHPNET, LAST_LANG, COUNTRY php only set's one cookie on the front page. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#185770) next »