how to get http_only cookies

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.

how to get http_only cookies

Postby ZMer2019 » Thu Jul 09, 2020 11:05 pm

In cefclient, I want to get a cookie of type http_only, but I found that there is no cookie of this type, what should I do?
here is my code:
Code: Select all
class CCookieVisitor: public CefCookieVisitor{
        static int sum ;
        bool Visit(const CefCookie& cookie, int count, int total, bool &deleteCookie)override {
            if( && cookie.value.str){
                CefString name =;
                CefString value = cookie.value.str;
                LOG(INFO)<<count<<" of "<<total<<" ||| "<< name.ToString() <<":" << value.ToString()<<"\n";
            return true;

bool ClientHandler::OnProcessMessageReceived(
            CefRefPtr<CefBrowser> browser,
            CefRefPtr<CefFrame> frame,
            CefProcessId source_process,
            CefRefPtr<CefProcessMessage> message) {
        LOG(INFO)<< "=========OnProcessMessageReceived\n";
        //LOG(INFO)<< request->GetURL().c_str();
        CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(nullptr);
        CefRefPtr<CCookieVisitor> visitor = new CCookieVisitor();
        if (message_router_->OnProcessMessageReceived(browser, frame, source_process,
                                                      message)) {
            return true;

        // Check for messages from the client renderer.
        std::string message_name = message->GetName();
        if (message_name == kFocusedNodeChangedMessage) {
            // A message is sent from ClientRenderDelegate to tell us whether the
            // currently focused DOM node is editable. Use of |focus_on_editable_field_|
            // is redundant with CefKeyEvent.focus_on_editable_field in OnPreKeyEvent
            // but is useful for demonstration purposes.
            focus_on_editable_field_ = message->GetArgumentList()->GetBool(0);
            return true;

        return false;
Posts: 1
Joined: Thu Jul 09, 2020 10:54 pm

Re: how to get http_only cookies

Postby magreenblatt » Fri Jul 10, 2020 10:58 am

CefCookie has an |httponly| member that you can check, and CefCookieManager::VisitUrlCookies has an |includeHttpOnly| parameter.
Site Admin
Posts: 10181
Joined: Fri May 29, 2009 6:57 pm

Return to Support Forum

Who is online

Users browsing this forum: amaitland, Google [Bot] and 39 guests