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

curl-and-php

Re: Re: Cookies

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 22 Oct 2001 10:52:12 +0200 (MET DST)

On Sun, 21 Oct 2001, Jeff B wrote:

> Apparently I don't understand the concept of the CURLOPT_COOKIEFILE. I
> am trying to post form info while maintaining a "jSession" with a servers
> java servlet.
>
> I had thought CURLOPT_COOKIEFILE would save the jsession id and post it
> when called later in the cURL session. I'm using cURL 7.6.1 on a Windows
> NT box.

CURLOPT_COOKIEFILE tells curl to *READ* cookies from the specified file. It
also tells curl to activate the cookie parser in the upcoming transfer.

To make curl store cookies after a session where the cookie parser was
activated, there are two separate options:

 CURLOPT_HEADERFUNCTION - which I don't know how or if it works with the
 PHP interface. You need to study the docs or get someone more familiar with
 that interface to respond. This is a callback that gets called for every
 received header, that could be used to store headers in a file, later to be
 fed to the CURLOPT_COOKIEFILE option.

 CURLOPT_COOKIEJAR - introduced in curl 7.9 (with some initial known
 problems). Pass a file name in which you want to have all known cookies
 written to when curl_easy_cleanup() is called.

In general, once you've activated the cookie parser, all cookies that curl
receives will be parsed and if you do any subsequent requests after that, the
appropriate cookie will be used from the ones just received -- automatically.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-10-22