views:

49

answers:

2

I asked on the C# MSDN forum with no response. =[ Basically I have made a programme which automates a website with several different accounts, one after the other. However the website stores a cookie to save the account to the computer so you can't log another account into the site for about 4 days. I can delete the cookie; however because my app hosts the web browser I need to be able to effectively restart it to the cookie from the temp file as well. Is there any way I can dispose and then recreate the control, as I would rather keep the same variable name. Any ideas welcome.

A: 

If you want to automate interaction with a website, you should use HttpWebRequest rather than a web browser control. The CookieContainer can hang on to cookies as long as you need them.

Jeremy Stein
+1  A: 

This applies to file cookies: How to clear the cache when your application hosts a WebBrowser control in Visual C# .NET

For http-only cookies, use InternetSetCookieEx.

Sheng Jiang 蒋晟