VenomFangs VenomFangs - 1 month ago 20
C# Question

Internet Explorer - Specify JSessionID by setting Session Cookie via Client Java or C# Code

In my code, I have a JSessionID, which I want to share with an IE instance.

I am able to launch an instance of IE, however I need to specify the JSessionID to the browser. The application server will be JBoss, WebSphere or WebLogic, so I am looking for a solution that sets the value via a session cookie (via local java or C# code, not server based code).

Please note that setting the JSessionID via the url or server does not help me for my scenario.

Answer

Use IE automation to set document.cookie.

Here are related questions - http://stackoverflow.com/search?q=%5Binternet-explorer%5D+automation and sample here http://www.c-sharpcorner.com/UploadFile/gcorrell/IEInstance12062005003909AM/IEInstance.aspx. Some documentation links - IWebBrowserApp and Document.cookie.

SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass();
IWebBrowserApp wb = (IWebBrowserApp) ie;
wb.Visible = true;
//Do anything else with the window here that you wish
wb.Navigate(url, ref o, ref o, ref o, ref o);
// add code to wait for navigation to complete... 
// i.e. by waiting for NavigateComplete2  event, or simply sleep...
wb.Document.cookie="....";
Comments