curl-library
Delete single cookie
Date: Thu, 31 Jul 2008 23:45:55 +0100
Hi guys,
Hopefully this is a simple issue to deal with. When I log into a website a
number of cookies are set and I want to delete one of them (it's deleted by
some javascript function on the website, I think, and isn't deleted by
libcurl using program automagically). To this end I made a function which
looks at all the cookies I've stored and copies the contents of the ones
that are to be kept. It then deletes "ALL" cookies and sets them again, but
this time with the contents of the string variable which holds the contents
of the required cookies.
So, if I print the cookies before the deletion and print them after the
deletion the cookie I want to delete remains present. The cookies are in the
format
domain TRUE / FALSE 10 cookie_name cookie_value
so I iterate through the list of cookies, and format a cookie string in the
the form of cookie_name=cookie_value;. Then I do a
curl_easy_setopt( curlHandle, CURLOPT_COOKIELIST, "ALL" );
curl_easy_perform( curlHandle);
curl_easy_setopt( curlHandle, CURLOPT_COOKIE, cookie_string );
curl_easy_perform( curlHandle);
where cookie_string is a list of cookies in cookie_name=cookie_value;...
etc. This should work, right? If not I'd appreciate some guidance on the
matter!
Thanks!
Received on 2008-08-01