Say I have a webbrowsercontrol inside a windows form, and the user logs in to a secure site from the form. If the user were to open IE separately, it would also show them logged in. Is it possible to isolate the windows form's IE instance?
4 Answers
The WebBrowser control is built on top of the WebBrowser ActiveX, which lies on top of the WinInet. So you should be able to affect its behavior through the WinInet API.
You can try calling InternetSetOption
WinInet API to set the INTERNET_OPTION_END_BROWSER_SESSION
option to end the current session and start new one. To ensure that the call will affect only the current process, use the INTERNET_HANDLE_TYPE_INTERNET
handle.

- 74,861
- 18
- 132
- 169
-
can you give an example of how to use the INTERNET_HANDLE_TYPE_INTERNET handle? Need to make sure that InternetSetOption does not affect Office. – tofutim Nov 12 '11 at 17:50
-
Just pass INTERNT_HANDLE_TYPE_INTERNET as the first parameter in your call to InternetSetOption. – Franci Penov Nov 12 '11 at 23:27
you don't mention your version; the behavior changed from IE7 to IE8.
In IE7 and IE6, you can open multiple windows and authenticate with different userids on one site.
In IE8, your session state is shared across browser sessions.
You can open IE with privacy mode on; this should allow the session to be sandboxed.

- 1,085
- 1
- 11
- 25
IE8 has the command line switch -nomerge
, which starts the browser with a new session

- 10,630
- 28
- 36
When you log into a site, you generally get a cookie passed to your from the server that marks you as "logged in" (VERY oversimplified....). My guess would be to delete the cookies. See here:
-
this doesn't work in case of SSL Client authentication with a certificate. You need to force INTERNET_OPTION_BROWSER_END_SESSION to remove also the information about the SSL certificate – madduci Jul 03 '17 at 08:27