W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2003

Re: cookie handling

From: Richard Atterer <richard@list03.atterer.net>
Date: Sun, 20 Jul 2003 17:24:29 +0200
To: www-lib@w3.org
Message-ID: <20030720152429.GA1888@elessar.lan>

Hello Raj,

On Thu, Jul 17, 2003 at 10:39:26AM -0400, Sinha, Raj (Raj) wrote:
> I am trying to parse the HTTP header.. Actually more interested in
> getting the Etag header.
> I have tried using the func HTResponse_etag(response) in terminate
> handler but cannot get the etag value (returns Null). I verify that the
> correct response object is being passed. Am I on the right track

Hm, I think so! Have you enabled libwww's logging? This may help you to 
find out whether the server sent an etag header and what libwww thought of 

On Sun, Jul 20, 2003 at 07:03:03AM -0400, Sinha, Raj (Raj) wrote:
> Can anyone please illustrate to me with code cookie handling behavior...
> An example of storage would be appreciated o get me started.. I seem to
> be going in circles

I have never used libwww's cookies before, but from a look at the docs the
following might be the way it works:

- Init other parts of libwww
- HTCookie_init()
- HTCookie_setCallbacks(setCookie, 0, findCookie, 0)
- .....Create and run HTRequests.....
- HTCookie_deleteCallbacks()
- HTCookie_terminate()

Now you need to write the two functions, setCookie() and findCookie(). The
first one looks at the cookie it is given and writes its data to a file (or
caches it in memory, whatever), possibly replacing an older version of the
same cookie.

The second one is given just a request and then needs to figure out which
cookies to send along with that request; it returns the list of cookies (I
guess). Typically, finding the cookies to send will involve looking at the
request's URL and scanning through the cookie file (or whatever) for
cookies with the same domain as the request. A complete implementation will
also remove cookies from the cookie file when they have expired (that is,
HTCookie_expiration()>time(NULL), at a guess).

Maybe have a look at the cookie "standard" at



  __   _
  |_) /|  Richard Atterer     |  GnuPG key:
  | \/|  http://atterer.net  |  0x888354F7
Received on Sunday, 20 July 2003 14:05:39 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:56 UTC