c++ - 有什么方法可以将 cookie 传递给 IWebBrowser2 导航

标签 c++ winapi cookies webbrowser-control iwebbrowser2

有什么方法可以将 cookie 传递给 IWebBrowser 的 Navigate 方法。

据我所知,无论是在 header 中传递 Cookie header 还是 InternetSetCookie/InternetSetCookieEx 都无法与 IE11 配合使用。

我发现唯一可行的方法是通过 IHTMLDocument2 的 put_cookie 设置 cookie,但为此你必须先加载页面。

有什么方法可以将 cookie 传递给 Navigate 的第一次调用吗?

最佳答案

你可以试试 IESetProtectedModeCookie如果您正在与低完整性浏览器控件进行交互。这仍然有限制,如 this cookie FAQ 中所述:

IE10+ on Windows 8+ introduced Enhanced Protected Mode which uses AppContainers (rather than Integrity Levels) for isolation. EPM does not offer an API for interacting with cookies; IESetProtectedModeCookie will not set the cookie inside an AppContainer.

没有记录创建 AppContainer,所以我假设您的进程没有在 AppContainer 中运行?

This newsgroup thread确认您不能在 header 中设置 cookie:

In case anybody is interested, I went through Microsoft support to find out more about this. Their answer: what I want to do is not supported. The 'headers' argument to Navigate/Navigate2 CANNOT be used to set cookies.

我猜想在 put_cookie 之后刷新页面是 Not Acceptable ?

关于c++ - 有什么方法可以将 cookie 传递给 IWebBrowser2 导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42488074/

相关文章:

c++ - PVS-Studio 知道 Unicode 字符吗?

c++ - LLVM:VS 2015中的链接错误

c++ - 获取函数参数名称visual studio

windows - 如何在 GetLastError() 返回 ERROR_MOD_NOT_FOUND 后获取丢失的 DLL 名称

winapi - 在 Win32 上创建新窗口时如何得到通知?

Android CookieManager setCookie 没有设置任何东西

c++ - 从双数据类型获取特定整数的方法

c++ - #define 带有 L 标识符的语法

python - 如何使用 urllib 发送 cookie

php - WHM mysql "SQLSTATE[HY000] [1045] Access denied for user"