window.open doesn't open in same session

Try this workaround, not sure it will help but worth a shot:

<a href="/path_to_same_page" target="mywindow" onclick="window.open('/path_to_same_page', 'mywindow', 'toolbar=0,status=0,resizable=1');">Click here...</a>

By having this, the window won't get opened by script initially, but rather by the target attribute.


Reason behind this behaviour is, the parent page is hosted on a IE web browser control embedded in our windows application. When it creates a new window (either using window.open or target="_blank"), the new window is owned by iexplore.exe process and doesn't inherit the session cookies from the parent IE window, which is owned by our application process. There is no generic solution to this problem. In our case, we used some kind of Single Sign On to share the session context between two window instances.


You stated in your answer that

the parent page is hosted on a IE web browser control embedded in our windows application

There actually is a solution to this problem. Your application needs to handle the NewWindow2 event in order to maintain the session across windows.

Refer to the following MSDN resources for details on this:

  • How to use the WebBrowser control NewWindow2 event in Visual C#
  • How to use the WebBrowser control NewWindow2 event in Visual Basic .NET
  • How To Use the WebBrowser Control NewWindow2 Event (for Visual Basic 5.0 and Visual C++ 5.0)