Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
Posted
Updated 26-Aug-18 5:06am

1 solution

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))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900