Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Webbrowser Control and cookies
 

Webbrowser Control and cookies

I want to be able to store seperate cookies in each web browser instance...

Yet I can't find out how they are stored, I can change them on the per-document level... but that wouldn't be a good idea would it? It would change global cookies too right?

Basically I want to create some kinda cookie container (not the one used for httpwebrequest...) and assign each browser it's own container...


I've also heard about extended web browser controls and web browser controls based off the firefox engine, wheres info on these, I can't find them.
Strange_Will  Monday, July 03, 2006 7:16 AM
You can't do this either for example if you had created your own request and response objects then you enter form data in the webbrowser control those cookies do not persist into the browser control and if you handled the navigating before the browser did and cancelled the browser from navigating then you'd still be left with the issue of handling the form data which would then defeat the whole purpose of using the WebBrowser control to begin with!
WillHelm  Sunday, April 15, 2007 11:24 AM
Hi Strange_Will,
An answer is coming quite late... but it may help others. So here a way to add a cookie to the webBrowser control: (works great!)

public partial class WebBrowserControl : Form
{
private String url;

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);

public WebBrowserControl(String path)
{
this.url = path;
InitializeComponent();

// set cookie
InternetSetCookie(url, "JSESSIONID", Globals.ThisDocument.sessionID);

// navigate
webBrowser.Navigate(url);
}
...
}

For more info, see this blog entry: http://en.gli.sh/Blog/default,month,2006-11.aspx
ClaudiaHelpOnVSTO  Thursday, January 11, 2007 3:54 PM
ClaudiaHelpOnVSTO wrote:
Hi Strange_Will,
An answer is coming quite late... but it may help others. So here a way to add a cookie to the webBrowser control: (works great!)

public partial class WebBrowserControl : Form
{
private String url;

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);

public WebBrowserControl(String path)
{
this.url = path;
InitializeComponent();

// set cookie
InternetSetCookie(url, "JSESSIONID", Globals.ThisDocument.sessionID);

// navigate
webBrowser.Navigate(url);
}
...
}

For more info, see this blog entry: http://en.gli.sh/Blog/default,month,2006-11.aspx


The problem isn't in setting cookies, its that I need each webbrowser instance to have it's own cookie container. You have to write your own httprequest/response interface for the browser. :P
Strange_Will  Thursday, January 11, 2007 4:15 PM
You can't do this either for example if you had created your own request and response objects then you enter form data in the webbrowser control those cookies do not persist into the browser control and if you handled the navigating before the browser did and cancelled the browser from navigating then you'd still be left with the issue of handling the form data which would then defeat the whole purpose of using the WebBrowser control to begin with!
WillHelm  Sunday, April 15, 2007 11:24 AM
I try it ,but not succeed!
Focus in C# developing
passkalilo  Monday, October 05, 2009 5:28 AM

You can use google to search for other answers

Custom Search

More Threads

• Dock Padding
• How to add controls(components) to a form at design time?
• Container Controls no longer accepting drag/dropped controls after a load
• Force UI of control to refresh on certain control property changed
• drag-and-drop,resize,and moving controls in runtime
• Problem with DataGridView CustomControl
• Designer auto assigning bogus string resource values
• WANTED : Full Featured Collapsible Panel
• Overriding the default Windows Forms IRootDesigner
• how to design the appearance of statusStrip?