Page 1 of 1

Synchronous cookie store access - is it possible?

PostPosted: Thu Nov 19, 2015 3:19 pm
by HarmlessDave
We are running into a problem interacting with a server that we do not control. It wants to set a security handshake challenge and then immediately look for the valid response.

With the IE web control, you can have a before navigate or document complete event check and update cookies synchronously, so the response is guaranteed to be there in the next request. With the aynch cookie visitor this might or might not happen in time.

Does chromium offer synchronous cookie access that CEF is not using because asynchronous is considered better, or is this something that could only be accomplished by hacking the chromium source?

Edit: this gets more complicated since navigation events are in the render process and the current cookie manager functions must be run in the browser process. Unless the render process could get direct access I guess this might require some duct tape and baling wire scheme like delaying all navigations while the cookie visitor is in progress. Ugly.

Re: Synchronous cookie store access - is it possible?

PostPosted: Thu Nov 19, 2015 3:23 pm
by magreenblatt
HarmlessDave wrote:Does chromium offer synchronous cookie access

No. You can look at the CookieMonster implementation for the full set of methods offered by Chromium.

Re: Synchronous cookie store access - is it possible?

PostPosted: Thu Nov 19, 2015 3:27 pm
by HarmlessDave
magreenblatt wrote:
HarmlessDave wrote:Does chromium offer synchronous cookie access

No. You can look at the CookieMonster implementation for the full set of methods offered by Chromium.


Thanks - if we can't get the partner to update their server I guess we'll need to implement some kind of halt-and-wait scheme where we cache the next navigation and stop it until after CookieVisitor reaches its destructor.

Re: Synchronous cookie store access - is it possible?

PostPosted: Thu Nov 19, 2015 5:32 pm
by magreenblatt
In modern CEF versions most requests can be continued asynchronously. You might want to see if that's an option for you.

Re: Synchronous cookie store access - is it possible?

PostPosted: Fri Nov 20, 2015 6:45 pm
by HarmlessDave
magreenblatt wrote:In modern CEF versions most requests can be continued asynchronously. You might want to see if that's an option for you.


Can you explain in a little more detail? If I want to wait for the cookie visitor in CefRenderProcessHandler - OnBeforeNavigation( ) I can't think of a way to delay it except for caching the request, blocking the navigation by returning true, then having the CookieVisitor destructor re-issue the request.

Which gets tricky, because how do I know to let that second version go through without re-doing the cookie wait? The URL will not be unique in situations like posting back a form on a page to itself. Maybe by creating a hash from the request and storing it as already checked?

If there's a cleaner way to delay a navigation until after the cookie visitor destructor, it would be very helpful to know that.

Edit: we're using CEF 3.2272.1998

Re: Synchronous cookie store access - is it possible?

PostPosted: Fri Nov 20, 2015 7:02 pm
by magreenblatt
The OnBeforeResourceLoad method can be continued asynchronously in newer CEF versions. You could use that to delay the request until cookie info is retrieved.