Don't send existing cookies, but still accept set cookies
I am looking at the Wininet APIs for cookies, and I cannot seem to find a flag for that would avoid sending cookies, but still accept them. I am trying to not send in the HTTP request the cookies currently in the machine, but still let the set cookie from the server response be set (and override any existing cookies).
The closest flag is INTERNET_FLAG_NO_COOKIES
, but that also does not add cookies to the cookie database:
INTERNET_FLAG_NO_COOKIES
0x00080000Does not automa开发者_StackOverflow中文版tically add cookie headers to requests, and does not automatically add returned cookies to the cookie database. This flag can be used by HttpOpenRequest and InternetOpenUrl (for HTTP requests).
One bad solution I found is to iterate through the cached entries with
FindFirstUrlCacheEntry
, FindNextUrlCacheEntry
and delete the entries associated with the URL with DeleteUrlCacheEntry
every time before the request is sent.
精彩评论