Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Set cookie before loading url WebEngineView(qml)
Forum Update on Monday, May 27th 2025

Set cookie before loading url WebEngineView(qml)

Scheduled Pinned Locked Moved Solved QtWebEngine
2 Posts 1 Posters 1.8k Views
  • 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.
  • H Offline
    H Offline
    HojjatJafary
    wrote on 1 Jul 2017, 17:23 last edited by
    #1

    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
    0
    • H Offline
      H Offline
      HojjatJafary
      wrote on 2 Jul 2017, 13:25 last edited by
      #2

      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
      0

      2/2

      2 Jul 2017, 13:25

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved