简体   繁体   中英

Setting cookies for the GeckoFX web browser?

How do you set the cookies for the Gecko web browser?

I know that I have to call:

geckowebbrowser.Document.Cookie = ...;

but you need to set the cookies globally too. For example, in the .NET included Microsoft IE WebBrowserControl you set them by using the following Winapi function:

static extern bool InternetSetCookie(string lpszUrl, string lpszCookieName,
                                     string lpszCookieData);

This works fine for IE Web Browser but not for Gecko.

I've tried to use the Cookiemanager class from the Gecko library by calling Cookiemanager.add(...)

This worked for me with geckofx browser 29.0:

string cookieName = "testName";
string cookieValue = "testValue";
geckoBrowser.Document.Cookie = string.Format("{0}={1}; {2}", cookieName, cookieValue, mainBrowser.Document.Cookie);

This updates or creates a cookie.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM