c# - Make .NET WebBrowser not to share cookies with IE or other Instances -


since webbrowser in c# shares cookies other instances of webbrowsers including ie webbrowser have it's own cookie container doesn't share cookies created in ie or other instances.

so example when create webbrowser shouldn't have cookies. , when run 2 instances of webbrowsers have own cookie container , don't share or conflict cookies each other.

how can achieve ?

you per process using internetsetoption win32 function:

[dllimport("wininet.dll", charset = system.runtime.interopservices.charset.auto, setlasterror = true)] public static extern bool internetsetoption(int hinternet, int dwoption, intptr lpbuffer, int dwbufferlength); 

and @ application startup call following function:

private unsafe void suppresswininetbehavior() {     /* source: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385328%28v=vs.85%29.aspx     * internet_option_suppress_behavior (81):     *      general purpose option used suppress behaviors on process-wide basis.      *      lpbuffer parameter of function must pointer dword containing specific behavior suppress.      *      option cannot queried internetqueryoption.      *           * internet_suppress_cookie_persist (3):     *      suppresses persistence of cookies, if server has specified them persistent.     *      version:  requires internet explorer 8.0 or later.     */       int 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 !>?");     } } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -