Setting cookies for the GeckoFX web browser?

断了今生、忘了曾经 提交于 2019-12-06 13:17:26

问题


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(...)


回答1:


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.



来源:https://stackoverflow.com/questions/12440083/setting-cookies-for-the-geckofx-web-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!