Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Save and restore cookies

Post Reply
igor666
Posts: 64
Joined: Fri Feb 08, 2019 1:25 pm

Save and restore cookies

Post by igor666 »

Hello, a question about adding cookies using TCefCookieManagerRef and the SetCookie function. I need to save cookies from some sites when I close the program, and these cookies need to be recreated at startup. Confuses the "url" parameter in the SetCookie function, since I get the cookie data using TCefFastCookieVisitor but it does not have the "url" parameter.
It turns out that when the program starts, I read the cookies that were saved and I don’t know what URL to specify when creating it. In theory, you can look at the "domain" parameter, but here another question arises, we do not know what to substitute "http" or "httpS" in front. After all, the domain of the site looks like "site.com" or ".site.com".
Could you tell me how to correctly substitute the "url" parameter in the SetCookie function?
Thank you.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Save and restore cookies

Post by salvadordf »

Sorry but I don't remember all the details about the cookies but I can give you the links to the information you need.

All the TChromiumCore.SetCookie parameters except aSetImmediately and aID are the cookie values that will be used by the cookie manager to set the new cookie.

This is the documentation and the code comments for the TCefCookie record :
https://cef-builds.spotifycdn.com/docs/106.0/structcef__cookie__t.html
https://bitbucket.org/chromiumembedded/cef/src/0089378a0a75b3cba4cd51f2497d8f5c302f0604/include/internal/cef_types.h#lines-749

This is the RFC for the cookies implemented by Chromium :
https://www.rfc-editor.org/rfc/rfc6265

The "secure" and "httponly" parameters should be enough to know if the URL scheme is http or https.
igor666
Posts: 64
Joined: Fri Feb 08, 2019 1:25 pm

Re: Save and restore cookies

Post by igor666 »

Thanks for the information, I haven't read everything yet, but I will read it :). It seems that in the "url" parameter it doesn't matter what is set to http or https, the cookie is still created with the following parameters. So I decided to try taking the "domain" parameter for now, remove the dot in front, if it exists, and substitute https and use this string as a url.
Post Reply