Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Create Cookie And Launch IE...

I have a Windows Forms app where I want to launch internet explorer and show a web page.  That's no problem.  Now I need to set a cookie with some data before I launch the page so that when the page is shown the cookie is read and the web app can respond to the data in the cookie.

Anyone know how to go about doing this?  Do I just write a cookie to the cookies folder of the users machine?  That could work but I was hoping to use a session/browser cookie, not a permanent one that's stored on the users machine.

Any tips/help would be much appreciated.

Thanks!
Thursday, June 02, 2005

BTW - I'm using

Process.Start(startInfo);

...to launch IE (I have the executable path stored in config) so I'm not sure if there's anyway to attach a session cookie using that method of starting IE.

Thanks!
Thursday, June 02, 2005

Stupid question, but can you pass information through the querystring instead of a cookie?

If it's a security issue or data issue, you could make a web service call to send the information to your server and create a temporary key. You'd pass in the key to the browser through the querystring, which would tell the server that this is a legitimate user and respond with the proper data. They key would be deleted after X minutes.

moron
Thursday, June 02, 2005

Unfortunately I can't pass the session info in the querystring for a number of reasons.

I'm getting closer with the WinInet function InternetSetCookie() but the problem in using this with Process.StartInfo("iexplore.exe") is that the InternetSetCookie() function sets a cookie to the process that calls the function (my windows application) and Process.StartInfo() spawns a new process that knows nothing about the cookie on the windows app process.

It doesn't seem logical to me, but is there a way an application can launch an IE window inside it's current process.  Maybe with threading somehow?

Thanks!
Thursday, June 02, 2005

How about just embedding the web browser ActiveX control in a windows form instead of launching IE as a separate process?

matt
Thursday, June 02, 2005

*  Recent Topics

*  Fog Creek Home