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

curl-and-php

Re: HTTPS and cURL in PHP

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Fri, 3 Sep 2004 09:31:54 +0200 (CEST)

On Fri, 3 Sep 2004, Frank wrote:

> I need to login to a https address, start a session and then download a
> particular file everyday.
>
> My Curl Options look like this
>
> $ch = curl_init();
> curl_setopt ($ch,CURLOPT_URL, $url);
> curl_setopt ($ch,CURLOPT_POST,1);
> curl_setopt ($ch,CURLOPT_POSTFIELDS, $data);
> curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookieFileName");

I take it this is the actual login request?

> but I keep getting this error : unable to save your session ID in a browser
> cookie. It needs to be able to do this in order to work properly.

>From where? Who says this? If the server responds with a message like that to
this request, then you probably miss something that the server uses to detect
if you can set a cookie. That is most likely a cookie from a previous page.

> Do I need to send any headers?

We can't tell, but the server somehow determines this and you need to figure
out how and take precautions.

> The cookie file can be just any file or must be a particular one?

The received cookies will be written to the given file. It can be anyone.

You don't even have to write them to a file if you don't want to (just
activate the cookie parser), as the cookies are kept internally in the handle
data so if you just re-use the handle it'll use the cookies it knows of.

-- 
      Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
       Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-09-03