Internet Explorer WebBrowser Control loses state when JScript performs a call to Window.Open

Session state for a web site is often stored in cookies.  If you use the WebBrowser control in an program and the target website responds to an action with a call to Window.Open, then mysteriously the cookies for that site are not transmitted with the request.

Window.Open creates a window using the IExplore.exe process since it does not have a parent window handle.  You cannot share cookies across processes.

Correct methods to use:

1. Change the jscript

You can change the jscript to use the parent application window handle and that will host that window in your application’s process. 

function MyShowModal()
                var args = new Object;
                args.window = window;
                showModalDialog("modal.asp", args);

2. Your application can host the New Window

If your application goes to web sites that are not under your control, you handle the NewWindow2 event from the browser control as covered in these KB articles:

How To Use the WebBrowser Control NewWindow2 Event

How to use the WebBrowser control NewWindow2 event in Visual Basic .NET .Net Version:

How to use the WebBrowser control NewWindow2 event in Visual C# .NET or in Visual C# 2005

Related article:
How to maintain the ASP.NET session state