curl-users
Cookies in a file
Date: Wed, 25 Oct 2000 08:49:13 -0500
(If this question has been asked before, could someone just point me towards the archived discussion? I looked through the past couple months though and couldn't find anything on this issue)
I'm aware of the use of -D to dump headers into a file, and of -b to retrieve cookies from the file. However, there seems to be a limitation here as compared to a typical browser. A browser stores up cookies over time, so if the web server sends three different cookies on three different requests in the same path, each subsequent request will send the server all three cookies. However, cURL only saves the cookie(s) that was SET on the most recent request into the dumped headers file, and the web server doesn't send back ALL of the cookies it received - it only sends back the ones it wants to explicitly set. Plus, if I try to use the same file on one request for both reading and saving cookie info, it appears (I'm guessing without peeking at the source code) that curl blanks out the contents of that file (maybe in preparation for dumping headers to it) before it reads the contents of the file (due to the -b flag).
So if I needed to use this mechanism to store up all three cookies, I'd have to parse out the Set-cookie lines myself and gather them up in a separate file (imagine a multi-page request sequence that builds up a couple different cookies depending on the form variables that were posted, etc).
I'm wondering whether there couldn't be a modification to -b (or perhaps a new flag altogether) that allows cURL to act a bit more like a true browser, by reading existing cookies from that file (without needing to store the rest of the headers too) and writing new cookies to the same file. That way I could do something like:
curl -b cookies http://webserver/cky.cgi?name=1
curl -b cookies http://webserver/cky.cgi?name=2
curl -b cookies http://webserver/cky.cgi?name=3
and get a different cookie from each request into the file, while still passing the server all previous cookies, based of course on expiration, path, etc...
I'm not familiar with the netscape cookie file format, but perhaps that would be the right choice for such a cookie file?
Have I missed something obvious, or am I correct in seeing this limitation?
--Kevin
Received on 2000-10-25