Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Set cookie before loading url WebEngineView(qml)

    QtWebEngine
    1
    2
    1410
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • HojjatJafary
      HojjatJafary last edited by

      Hi,
      How can I set cookie before loading a url on WebEngineView that is created in qml code, can I inherit from something like WebEngineViewItem to create my customized WebEngineView?
      the WebEngineView widget has a page() method that return page and then I can get profile and then the cookieStore but I didn't find any way for qml code.

      1 Reply Last reply Reply Quote 0
      • HojjatJafary
        HojjatJafary last edited by

        Seems this is OK,

        QQuickWebEngineProfile* defaultProfile = QQuickWebEngineProfile::defaultProfile();
        QWebEngineCookieStore *cookieStore = defaultProfile->cookieStore();
        
        QNetworkCookie cookie;
        cookie.setDomain("domain.com");
        cookie.setName("devmode");
        cookie.setValue("true");
        
        cookieStore->setCookie(cookie);
        

        You can also pass the profile property of the WebEngineView from Qml to C++ and do same.
        There is no page method for Qml WebEngineView.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post