Alright I was given a link (http://support.microsoft.com/kb/195192) along with InternetSetOption(0, INTERNET_OPTION_END_BROWSER_SESSION, 0, 0); and told it should force 2 browsers in the same application to use 2 different cookies.

I ran it through the code translator and got the following.

const int INTERNET_OPTION_END_BROWSER_SESSION = 42;

[DllImport("wininet.dll", EntryPoint="InternetSetOptionA")]
    private static extern int InternetSetOption(long hInternet, long lOption, ref Any sBuffer, long lBufferLength);
    
    public int flushCredentials() {
        int h;
        h = InternetSetOption(0, INTERNET_OPTION_END_BROWSER_SESSION, 0, 0);
        return h;
    }

Most of the time I will sit for hours or days screwing with the code until I have it figured out but as this is for a generalized usage, I have no clue how to "assign" the call to a specific web browser. The application uses 2 web browser controls.

Can anyone help or at least point me in the right direction?
Thanks.

[Edit]
Also, is "h" in flushCredentials() returned as a success/fail int result?

I'm now able to get it running via each browser's handle.

private void Form1_Load(object sender, EventArgs e)
		{
			flushCredentials(webBrowser1.Handle);
			flushCredentials(webBrowser2.Handle);
		}
		const int INTERNET_OPTION_END_BROWSER_SESSION = 42;
		[DllImport("wininet.dll", EntryPoint = "InternetSetOption")]
		private static extern int InternetSetOption(IntPtr hInternet, int lOption, int sBuffer, int lBufferLength);
		public int flushCredentials(IntPtr handle)
		{
			int h;
			h = InternetSetOption(handle, INTERNET_OPTION_END_BROWSER_SESSION, 0, 0);
			return h;
		}

However, the problem persists that both controls are still using the same session

So the correcy C# syntax is

const int INTERNET_OPTION_END_BROWSER_SESSION = 42;
		[DllImport("wininet.dll", SetLastError = true)]
		public static extern bool InternetSetOption(IntPtr hInternet,nt dwOption, IntPtr lpBuffer, int dwBufferLength);

And is then called using

InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0);

Returning true and false upon success or failure, respectively.

However, this resets the session info for every browser within the application, not for the individual browser. So if you have one browser, you're good to go. If not (like me) you're still not done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.