The example in this article describes how C # clears the cookie cache in WebBrowser. Share to everyone for your reference, specific as follows:
Recently used C # to write a program, with a form of WebBrowser to log on the site, but WebBrowser have cookie cache, the second landing WebBrowser is still the first time after the state, So to clear the WebBrowser cookie cache.
Find a piece of code available on the StackOverflow:
[DllImport ("Wininet.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)] public static
extern bool InternetSetOption (int hinternet, int dwoption, IntPtr lpbuffer, int dwbufferlength); private unsafe void Suppresswininetbehavior () {/* source:http://msdn.microsoft.com/en-us/library/windows/desktop/ Aa385328%28v=vs.85%29.aspx * Internet_option_suppress_behavior (Bayi): * A General purpose OPTION This is used to supp
Ress behaviors on a process-wide basis.
* The lpbuffer parameter of the function must is a pointer to a DWORD containing the specific behavior to suppress.
* This option cannot is queried with internetqueryoption. * * Internet_suppress_cookie_persist (3): * Suppresses the persistence of cookies, even if the server has Specifi
ed them as persistent.
* Version:requires Internet Explorer 8.0 or later.
* * option = (int) 3/* internet_suppress_cookie_persist*/;
int* optionptr = &option; BOOL Success = inteRnetsetoption (0, 81/*internet_option_suppress_behavior*/, new IntPtr (optionptr), sizeof (int));
if (!success) {MessageBox.Show ("something went wrong!>?");
}
}
Read more about C # Interested readers can view the site topics: "C # Common control usage Tutorial", "C # Data structure and algorithm tutorial", "C # object-oriented Program design Introductory Course" and "C # Programming Thread Usage Skills Summary"
I hope this article will help you with C # programming.