I'm integrating CEF with my MFC application (I'm following this tutorial) and i don't know how to get the request cookies, i'm trying in the OnBeforeBrowse method but still no success i also tried in the OnResourceResponse but i only manage to get some cookies inside the response.
A couple beginner questions: What the GetFirstPartyForCookies method does? i read the documentation and still didn't understood. Was i supose to use the CefCookieManager? i thought i should use the VisitAllCookies method but the visitor parameter can't be empty it gives me an Assertion, i'm trying:
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(NULL);
CefRefPtr<CefCookieVisitor> visitor;
manager->VisitAllCookies(visitor);
Any help or hint will be appreciated.
Found this answer on the CEF forum.
To retrieve the cookie i must create my own class derived from CefCookieVisitor and then call VisitAllCookies
CefRequestHandler::ReturnValue ClientHandler::OnBeforeResourceLoad(CefRefPtr< CefBrowser > browser,
CefRefPtr< CefFrame > frame,
CefRefPtr< CefRequest > request,
CefRefPtr< CefRequestCallback > callback)
{
auto strURL = request->GetURL();
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(NULL);
CefRefPtr<MyCookieVisitor> visitor = new MyCookieVisitor();
manager->VisitAllCookies(visitor);
return RV_CONTINUE;
}