有什么方法可以将 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/