Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WebBrowser control shares cookies between multiple instances
#1
FYI - I just had an odd problem with a program I set up for load testing a server using the WebBrowser control. If you open multiple WebBrowser controls in separate threads in a single process they will share cookies; in my program each thread authenticated separately and each thread would overwrite the cookies from the other threads - the result wasn't pretty Big Grin

By default the WebBrowser controls also share cookies between processes. Here's a utility that turns that feature off:
Function SuppressIECookies
Code:
Copy      Help
function
;http://stackoverflow.com/questions/18195844/make-net-webbrowser-not-to-share-cookies-with-ie-or-other-instances
def INTERNET_OPTION_SUPPRESS_BEHAVIOR 81
def INTERNET_SUPPRESS_COOKIE_PERSIST 3

int option = INTERNET_SUPPRESS_COOKIE_PERSIST
int sizeOfInt = 32

InternetSetOption(0 INTERNET_OPTION_SUPPRESS_BEHAVIOR &option sizeOfInt)

I don't know if this will be useful for anyone else - but it was very useful for me. More explained in the URL that is in the QM comment in the code.
#2
Usually "size of" is in bytes, not bits. sizeof(int) is 4 bytes.


Forum Jump:


Users browsing this thread: 1 Guest(s)