为GeckoFX Web浏览器设置cookie吗? [英] Setting cookies for the GeckoFX web browser?

查看:178
本文介绍了为GeckoFX Web浏览器设置cookie吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为Gecko Web浏览器设置cookie?

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

我知道我必须打电话:

geckowebbrowser.Document.Cookie = ...;

,但是您也需要全局设置Cookie。例如,在包含.NET的Microsoft IE WebBrowserControl中,可以使用以下Winapi函数对其进行设置:

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);

此功能对于IE Web浏览器有效,但不适用于Gecko。

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

我尝试通过调用Cookiemanager.add(...)

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

推荐答案

这与geckofx浏览器29.0配合使用:

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);

此更新或创建cookie。

This updates or creates a cookie.

这篇关于为GeckoFX Web浏览器设置cookie吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆