user6
user6

Reputation: 2043

Add cookies to webbrowser control in C#

I have a WebBrowser Control, I'd like to add all of the cookies of my FireFox browser so that I'll automatically signed in at the sites i visit. I'm already reading all of my firefox cookies but no seek to add them to my custom webbrowser.

Is this even possible?

Upvotes: 1

Views: 3542

Answers (2)

user6
user6

Reputation: 2043

The following seems to work:

Declare method InternetSetCookie

[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool InternetSetCookie(string url, string name, string data);

And than use it like:

InternetSetCookie("http://myDomain.com", "name", "value");

Upvotes: 3

Nipun Ambastha
Nipun Ambastha

Reputation: 2573

The first thing about cookies is it doesn't allow access of cookies of different browser as it is saved using Guid.

So you have to try different approch by saving cookies on Server or try out session or try out creating browsers cookie on itself.

Upvotes: 2

Related Questions