index > Visual C# General > Clearing Cookies

Clearing Cookies

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

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.

Odie5533
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.



** Microsoft Community Moderator ** http://born2code.net **
PJ. van de Sande
I actually want to clear all cookies except one from a specific domain.
Odie5533
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.



** Microsoft Community Moderator ** http://born2code.net **
PJ. van de Sande

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);
}

Odie5533
reply 6

You can use google to search for other answers

 

More Articles

• How do I insert this Statement using CodeDOM
• How to set a ConnectionString Setting at runtime?
• C# SetItemData() please help
• what is #if used for?
• How To called Managed Code from Unmanaged Code ?
• using the ScriptControl
• VS 2005 My things that I don?? like list?
• hashMd5 .ToString() arguments
• Application references
• messagebox
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Unique Machine ID
• Tooltip Text
• Exception handling shortcuts?
• Passing a string from a C# program to a
• Comboboxes datasets, text and values
• Get resource without knowing absolute path
• Deleting a row in excel sheet using C#
• get a list of all local drives?
• How to overwrite an existing Bitmap file
• Thread cannot access static variable
• Open Windows Media Player. . .
• How to Display ASP.NET Template Contents
• C#- Connect to a streaming radio station
• Special Assignement
• Image Transfer via Remoting

Hot Articles

• figuring out what was clicked on a form
• Postback in Asp.Net and C#
• How to insert a table into HTML page wit
• UserControl Events
• Call C++ dll from C#
• override static methods
• Weird problem with Button.Image
• How do you merge a ContextMenuStrip with
• DataGridViewButtonColumn Text
• Converting A Formula Into A Number
• How can I know the picture type from Ima
• How to set form icon; it doesn't work fo
• Raise an event from a User Control.
• SMS Creating collection with SMS SDK and
• How to make palettes in C#[Windows] whic

Recommend Articles

• use ActiveX ctrl if available
• Error when trying to compile a program
• How do I call unmanaged function : func(
• how to open a file implicitly when appli
• Best way to get login for HTTP authentic
• DTS 2000 with WMI
• ErrorProvider makes default language loo
• Calling C dll in c#: please help: Access
• Integration of MSDN Library 2005 beta in
• How can I store settings in the registry
• The best way
• Datagridview control help to retrive dat
• exception on eventhandler SelectedIndexC
• How to Display Image From Byte
• Authentication Method