cookie

Post Reply
kotyara
Posts: 12
Joined: Fri Sep 04, 2020 11:06 am

cookie

Post by kotyara »

Hello, i would like to know :
How to assign a separate folder for storing cookie and cache for each and every Chromium
I used to do it like that:

Code: Select all

String sCookies = "C://qwe/br_1/CookiesDir";
String sCache = "C://qwe/br_1/CacheDir";
_di_ICefRequestContext FRequestContext = TCefRequestContextRef::New(sCache, L"en-US,ru-RU", true, true, true, false);
Chromium->CreateBrowser(CEFWindowParent, "Browser"+IntToStr(i), FRequestContext, sCookies, true);
But everything has changed, can you help me?
User avatar
salvadordf
Posts: 2987
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: cookie

Post by salvadordf »

Hi,

CEF removed the possibility to use a different directory for the cookies several months ago.
If you use the latest CEF libraries then you can only set the cache directory. The cookies will be stored in the same directory as the cache.

If you want to create a bunch of independent browsers in one application you can use a very similar code than the one you gave.

You would only have to create a request context with an independent "cache" parameter for each browser.
The MDIBrowser demo has all the code you need :
https://github.com/salvadordf/CEF4Delph ... m.pas#L217

This forum thread has more detials :
viewtopic.php?f=8&t=1122
kotyara
Posts: 12
Joined: Fri Sep 04, 2020 11:06 am

Re: cookie

Post by kotyara »

There was a problem like this:
Does the "Cookies" file contain only a name without a value? What could be the reason?
Снимок.PNG
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 2987
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: cookie

Post by salvadordf »

That file is managed by Chromium internally.

I could be wrong but the real value might be hidden in the "encrypted_value" column.
kotyara
Posts: 12
Joined: Fri Sep 04, 2020 11:06 am

Re: cookie

Post by kotyara »

Yes, there is data in this column, I did not notice it.
But the next time I start the program, I am not authorized on the site again. =(
kotyara
Posts: 12
Joined: Fri Sep 04, 2020 11:06 am

Re: cookie

Post by kotyara »

Here's another thing I noticed:
If the program is given a cookie file from the old version, where the value is not encrypted, it will start authorized on the site and everything is OK, but after closing it, it will move the value to "encrypted_value" and at the next launch it will start not authorized.
User avatar
salvadordf
Posts: 2987
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: cookie

Post by salvadordf »

Please, check that you set GlobalCEFApp.RootCache property before the GlobalCEFApp.StartMainProcess call in the DPR file.

GlobalCEFApp.RootCache must be a parent directory to all the cache directories used by the browsers in your application as explained here :
viewtopic.php?f=8&t=1122&start=10#p6242

This is very important to Chromium because it stores a file called "LocalPrefs.json" with the keys to decrypt the cookie values in that directory. Without it, the browser will not be able to decrypt the cookies and the session will be closed the next time you open that website.
Post Reply