Clearing Cookies

Is there a way to clear a specific domain's cookies using WinInet while running Internet Explorer/WebBrowser Component

Answer this question

Clearing Cookies

  • Beav1810

    Then just get all cookies by specifying a empty url and then lookup the result, if a cookies doesn't is from a specific domain remove it.

    You can do this with the methods i supplied in my last post.


  • _ _

    I actually want to clear all cookies except one from a specific domain.
  • Kees van der Oord

    When I specify null or an empty set for the url, I don't seem to get any cookies let alone all of them. This is the code I'm using:

    public static void clearCookies()
    {
    string szURL = "";
    int dwSize = 256;
    StringBuilder lpszData = new StringBuilder(dwSize);

    if (!InternetGetCookie(szURL, null, lpszData, ref dwSize))
    {
    if (dwSize < 0)
    return;
    lpszData = new StringBuilder(dwSize);
    InternetGetCookie(szURL, null, lpszData, ref dwSize);
    }

    MessageBox.Show("Cookie: " + lpszData);
    }


  • TechCzech

    You can use InternetGetCookie to retrieve cookies for the specified URL and all its parent URLs.

    Use InternetSetCookie with a expires date that is in the past to remove it.

    A lillte resource page: Managing Cookies.


  • KevinUT

    I found this article:

    http://support.microsoft.com/default.aspx/kb/326201/EN-US/

    But I just don't know how to selectively clear cookies only, or selectively clear the cache of a single domain. Any help would be greatly appreciated.


  • Clearing Cookies