Notified on read/write cookie

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Notified on read/write cookie

Postby callum » Wed Sep 25, 2024 3:51 pm

CEF 128

I think I need create my own cookie manager and I thought I knew how to write code that was notified when a page either read or wrote a cookie but I was mistaken (I was thinking of the GetCookieManager::SetCookie() API for example).

Is there a way to do what I need?
callum
Expert
 
Posts: 332
Joined: Mon Feb 23, 2015 6:19 pm

Re: Notified on read/write cookie

Postby simonpearce » Mon Sep 30, 2024 6:19 pm

Apologies for bumping this question but is there really no interface to monitor when a cookie is read or written?

I haven't been able to find one but I would like to be sure before I give up and try a different approach to my problem.
simonpearce
Techie
 
Posts: 45
Joined: Tue Oct 27, 2015 2:32 pm

Re: Notified on read/write cookie

Postby magreenblatt » Mon Sep 30, 2024 6:46 pm

What is your end goal?

The cookie backend cannot be replaced with a custom implementation. CefCookieManager can be used to set and query cookies, and CefResourceRequestHandler::GetCookieAccessFilter can be used to control cookie access on a per-request basis.
magreenblatt
Site Admin
 
Posts: 12947
Joined: Fri May 29, 2009 6:57 pm

Re: Notified on read/write cookie

Postby callum » Tue Oct 01, 2024 1:31 pm

magreenblatt wrote:What is your end goal?

The cookie backend cannot be replaced with a custom implementation. CefCookieManager can be used to set and query cookies, and CefResourceRequestHandler::GetCookieAccessFilter can be used to control cookie access on a per-request basis.


A bunch of us have been discussing this elsewhere...

Our application launches multiple processes each of which renders content offscreen using CEF.

The piece that has never worked well (and documented as such) is sharing cookies/cache between them but it worked well enough for our use case up to now.

After recently updating to CEF 128, it was clear that this is no longer possible and (I think) expressly prohibited so we needed another solution.

Rearchiecting our application to only use one instance would be a very large task.

One option we considered was to write our own cookie store that was able to read/write cookies from multiple processes but to do that, we would need to intercept the CEF cookie read/write in each instance.

It sounds like that is not possible so I'm not sure what to do now.
callum
Expert
 
Posts: 332
Joined: Mon Feb 23, 2015 6:19 pm

Re: Notified on read/write cookie

Postby magreenblatt » Tue Oct 01, 2024 3:27 pm

What operating systems do you need to support?

One option might be moving CEF/Chromium execution to a (single) separate process and using a shared surface between processes for rendering. You would need to implement your own IPC approach for synchronization, CEF callbacks, and for calling CefBrowserHost methods.
magreenblatt
Site Admin
 
Posts: 12947
Joined: Fri May 29, 2009 6:57 pm

Re: Notified on read/write cookie

Postby magreenblatt » Tue Oct 01, 2024 3:29 pm

One option we considered was to write our own cookie store that was able to read/write cookies from multiple processes but to do that, we would need to intercept the CEF cookie read/write in each instance.

You can get/set cookies from the CefCookieManager in each process. Conflict resolution may be a problem.
magreenblatt
Site Admin
 
Posts: 12947
Joined: Fri May 29, 2009 6:57 pm

Re: Notified on read/write cookie

Postby callum » Tue Oct 01, 2024 4:23 pm

magreenblatt wrote:What operating systems do you need to support?

Windows, macOS and Linux

magreenblatt wrote:One option might be moving CEF/Chromium execution to a (single) separate process and using a shared surface between processes for rendering. You would need to implement your own IPC approach for synchronization, CEF callbacks, and for calling CefBrowserHost methods.?

That's a pretty good description of how it works now actually except that each time web content is required, a new process starts up and renders into a surface shared between itself and the main application

I wrote a standalone test mule that creates what amounts to a new 'tab' for each instance - when testing it with a selection 16 common sites and my own web based test apps, the cookies/cache work perfectly.

Bringing that code and the (ancient) code in the main application together is where I'm having trouble but that seems like the only path forward.
callum
Expert
 
Posts: 332
Joined: Mon Feb 23, 2015 6:19 pm

Re: Notified on read/write cookie

Postby callum » Wed Nov 06, 2024 8:14 pm

I came across an interesting solution to this problem - each CEF instance creates a symlink to a single cache/cookies folder and then passes that symlink into the CefSettings members for root_cache_path etc.

I'm told it works but I'd love to get your opinion @magreenblatt on whether it's likely to continue to do so as CEF is updated and if so, how likely it is to lead to the types of corruption called out in the docs as a reason to enforce the single folder paradigm?
callum
Expert
 
Posts: 332
Joined: Mon Feb 23, 2015 6:19 pm

Re: Notified on read/write cookie

Postby magreenblatt » Wed Nov 06, 2024 8:22 pm

how likely it is to lead to the types of corruption called out in the docs as a reason to enforce the single folder paradigm?

Very likely.
magreenblatt
Site Admin
 
Posts: 12947
Joined: Fri May 29, 2009 6:57 pm

Re: Notified on read/write cookie

Postby callum » Thu Nov 07, 2024 11:01 am

So you're saying there's a chance it could work :)

Thank you for the insight - will keep working on alternative solutions.
callum
Expert
 
Posts: 332
Joined: Mon Feb 23, 2015 6:19 pm

Next

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 43 guests