如何在C ++控制台应用程序的边缘浏览器中存储cookie? [英] How to store cookies in edge browser from a C++ console application ?

查看:119
本文介绍了如何在C ++控制台应用程序的边缘浏览器中存储cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我可以通过从我的C ++控制台应用程序调用IESetProtectedModeCookie API来在IE中存储cookie。

但是,这个方法在微软边缘浏览器中不起作用。

边缘浏览器中是否有任何替代方法可以存储来自C ++应用程序的cookie?



谢谢

Paul



我尝试过:



Hi,

I am able to store cookies in IE by calling IESetProtectedModeCookie API from my C++ console app.
However, this method is not working in microsoft edge browser.
Is there any alternative available in edge browser to store cookies from a C++ application ?

Thanks
Paul

What I have tried:

InternetSetCookie(url, cookieName, szCookieVal);




IESetProtectedModeCookie(url, cookieName, szCookieVal, NULL);

推荐答案

以下代码 [ ^ ]适用于Microsoft Edge。它不是用c ++而是你可以从中学习如何做到这一点。



The following code[^] works with Microsoft Edge. It is not in c++ but you can learn from it how to do it.

import win32inet
cookie_string = cookie
if cookie.find('xpires') == -1:
   expires = datetime.utcnow() + timedelta(days=30)
   expires_string = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
   cookie_string += '; expires={0}'.format(expires_string)
logging.debug("Setting cookie: %s", cookie_string)
win32inet.InternetSetCookie(url, None, cookie_string)
except Exception as err:
   logging.exception("Error setting cookie: %s", str(err))


这篇关于如何在C ++控制台应用程序的边缘浏览器中存储cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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