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



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.