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. Cookie is not set for all the calls which are initiated from inside of a jsp call.
Qt 6.11 is out! See what's new in the release blog

Cookie is not set for all the calls which are initiated from inside of a jsp call.

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 430 Views 1 Watching
  • 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
    Hetal
    wrote on last edited by Hetal
    #1

    I am making a call to a jsp file using QWebEngine. In that I am passing my Session Id which goes correctly.
    And I am setting the Cookie in the cookie store using a QWebEngineProfile. The cookie gets set for my first call but then it is not been set for other calls which are initiated from the jsp.

    *QWebEngineSettings webEngineSettings = QWebEngineSettings::defaultSettings(); webEngineSettings>setAttribute(QWebEngineSettings::WebAttribute::AutoLoadImages, true); webEngineSettings>setAttribute(QWebEngineSettings::WebAttribute::JavascriptEnabled, true);
    webEngineSettings>setAttribute(QWebEngineSettings::WebAttribute::LocalStorageEnabled, true);

    QWebEngineProfile* profile = new QWebEngineProfile("abc", parent);
    profile->setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies);
    profile->setHttpCacheType(QWebEngineProfile::HttpCacheType::MemoryHttpCache);
    profile->setHttpCacheMaximumSize(10);
    QWebEngineCookieStore* cookieStore = profile->cookieStore();
    cookieStore->loadAllCookies();
    QNetworkCookie* webEngineNewCookie = new NetworkCookie(QByteArray("MyCookie"), QByteArray("1234"));
    QUrl url = "https://example.com/help.jsp"
    cookieStore->setCookie(*webEngineNewCookie, QUrl(url));
    QStringList location = QStandardPaths::standardLocations(QStandardPaths::CacheLocation);
    profile->setPersistentStoragePath(location.at(0));

    QWebEnginePage* page = new QWebEnginePage(profile,parent);
    page->action(QWebEnginePage::WebAction::InspectElement);

    QWebEngineHttpRequest* webEngineHttpReq = new QWebEngineHttpRequest(QUrl(url), QWebEngineHttpRequest::Post);
    parent->setPage(page);
    parent->load(webEngineHttpReq);*

    When I make this call then I do get the cookie in this (https://example.com/help.jsp) but after this another calls are initiated from help.jsp those call does not have may cookies so they are blocked by the server.

    1 Reply Last reply
    0

    • Login

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