EDIT: As far as I know, there is no solution to this problem, making it yet another testament to the fact that one should not use C#'s WebBrowser. We ended up with a warning sign at the start of our program, notifying the user that cookies will be cleared for IE.

The short version of what I'm trying to do is in the title. Here's the long version.

I have a bit of a complex problem which I'm sure I will receive a lot of guesses as a response to. In order to keep the well-intended but unfortunately useless guesses to a minimum, let me first mention that the solution to this problem is not simple, so simple suggestions will unfortunately not help at all, even though I appreciate the effort.

The .NET WebBrowser component is fundamentally IE itself so solutions with any sorts of caveats will almost certainly not work. I need to do exactly what I'm trying to do, and even a seemingly minor caveat will defeat the purpose completely. At the risk of sounding arrogant, I need assistance from someone who really has in-depth knowledge about the .NET WebBrowser and/or WinInet and/or how to communicate with Windows's underlying system from C#... or how to encapsulate C++ code in C#.

That said, I don't expect anyone to do this for me, and I've found some promising hints which are explained later in this question.

But first... what I'm trying to achieve is this.

I have a Windows.Forms component which contains a WebBrowser control. This control needs to:

  1. Clear ALL cookies for ALL websites.
  2. Visit several websites, one after another, and record cookies and handle them correctly. This part works fine already so I don't have any problems with this.
  3. Rinse and repeat... theoretically forever.

Now, here's the real problem. I need to clear all those cookies (for any and all sites), but only for the WebBrowser control itself and NOT the cookies which IE proper uses. What's fundamentally wrong with

Edit
Report