CefURLRequestClient & CookieManager

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.

CefURLRequestClient & CookieManager

Postby js532 » Sat May 14, 2016 11:46 am

Hello,

Is there any tutorial how to use the cookie manager for a own client?
For me it won't work any I tried several things, already.

Code: Select all
class MyRequestContextHandler : public CefRequestContextHandler
{
private:
   IMPLEMENT_REFCOUNTING(CRequestContextHandler);

public:
   virtual CefRefPtr<CefCookieManager> GetCookieManager() OVERRIDE
   {
      return CefCookieManager::GetGlobalManager(NULL);
   }
};
...
CefRequestContextSettings settings;
CefRefPtr<CefRequestContextHandler> contextHandler = new CRequestContextHandler();
CefRefPtr<CefRequestContext> requestContext = CefRequestContext::CreateContext(settings, contextHandler);
CefRefPtr<CefURLRequest> urlRequest = CefURLRequest::Create(request, new CURLRequestClient, requestContext);
...


GetCookieManager is never being called. Request and Response works perfectly.
Also the cookie manager of the newly created requestContext points not to the GlobalManager.

I have no problems visiting cookies with my main browser, but the request client doesn't visit any cookie at all when calling visit all cookies in function OnRequestComplete.
However, I received a few cookies on the response header, so how can this be?

Even when swapping the CefRequestContext default cookie manager with the globalmanager or using the default cookie manager from the context - CefCookieVisitor::Visit will not get called.
I don't think my problem lies in CefCookieVisitor::Visit, since it works with the main browser.

Is this a bug? I can't find anything related to CefURLRequestClient and the cookie manager.

- Note that, if I use the main browser, everything works fine.
js532
Newbie
 
Posts: 7
Joined: Mon Apr 04, 2016 6:03 pm

Re: CefURLRequestClient & CookieManager

Postby HarmlessDave » Sat May 14, 2016 9:56 pm

I have no problems visiting cookies with my main browser, but the request client doesn't visit any cookie at all when calling visit all cookies in function OnRequestComplete.


Are the render process and browser process separate in your application? In a multi-process build Visit must be called from the browser / UI process NOT the render process. If that is the problem try sending a message / task to the browser process to ask it to visit the cookies.

Also, we have not had any need to create a separate cookie manager for URL requests, the global manager works.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: CefURLRequestClient & CookieManager

Postby js532 » Sun May 15, 2016 12:27 pm

I tried it with setting single process as true, already.

When and where should I make a call to Visit? I want to get the cookies right after the request of the url request client finished .
js532
Newbie
 
Posts: 7
Joined: Mon Apr 04, 2016 6:03 pm

Re: CefURLRequestClient & CookieManager

Postby js532 » Thu May 19, 2016 7:32 pm

Got the issue.

It was because I did not set UR_FLAG_ALLOW_CACHED_CREDENTIALS as flag for each request.
Also I needed a custom cookie manager. (If not, it would give a error message that no cookie backing path is set)
js532
Newbie
 
Posts: 7
Joined: Mon Apr 04, 2016 6:03 pm

Re: CefURLRequestClient & CookieManager

Postby magreenblatt » Thu May 19, 2016 10:12 pm

js532 wrote:Got the issue.

It was because I did not set UR_FLAG_ALLOW_CACHED_CREDENTIALS as flag for each request.
Also I needed a custom cookie manager. (If not, it would give a error message that no cookie backing path is set)

Or maybe set CefSettings.cache_path?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 77 guests