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. Save Cookies in Qt6.2.4 ?
Forum Updated to NodeBB v4.3 + New Features

Save Cookies in Qt6.2.4 ?

Scheduled Pinned Locked Moved Solved QtWebEngine
20 Posts 2 Posters 2.6k 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.
  • P Offline
    P Offline
    Paullux
    wrote on last edited by
    #1

    hello, since i change Qt5 to Qt6 for my app, that's worked for Qt5 (to save the cookies), doesn't work now :

        QString home=QDir::homePath();
    
        QWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
        QWebEngineProfile* defaultProfile = QWebEngineProfile::defaultProfile();
    
        defaultProfile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
        defaultProfile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
        QHttpPart* header = new QHttpPart;
        header->setRawHeader("X-Frame-Options", "ALLOWALL");
    
    #ifdef __linux__
        defaultProfile->setCachePath(home + ".FranceTV/cache/");
        defaultProfile->setPersistentStoragePath(home + ".FranceTV/persistentstorage/");
    #elif _WIN32
        defaultProfile->setCachePath(home + "/AppData/Roaming/FranceTV/cache/");
        defaultProfile->setPersistentStoragePath(home + "/AppData/Roaming/FranceTV/persistentstorage/");
    #elif __APPLE__
        defaultProfile->setCachePath(home + "/Library/Application Support/FranceTV/cache/");
        defaultProfile->setPersistentStoragePath(home + "/Library/Application Support/FranceTV/persistentstorage/");
    #endif
    
    1 Reply Last reply
    0
    • P Offline
      P Offline
      Paullux
      wrote on last edited by
      #20

      The Solution is :

          QWebEngineProfile *profile = new QWebEngineProfile(QString::fromLatin1("MyApplication.%1").arg(qWebEngineChromiumVersion()));  // unique profile store per qtwbengine version
          QWebEnginePage *page = new QWebEnginePage(profile); // page using profile
          QWebEngineView *view = new QWebEngineView();
      
          view->setPage(page);
          view->setUrl(AccueilUrl);
          view->setZoomFactor(1.2);
      
          setCentralWidget(view);
      
      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        What do you mean by does not work ?
        Files are not written ?
        Cookies are not read back ?

        Out of curiosity, why not use QStandardPaths rather than hard code each system path ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Paullux
          wrote on last edited by
          #3

          First, The files aren't write.

          And the app don't read the old cookies from Qt5 version.

          and how to use QStandardPaths ?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            Did you check whether the path has been updated correctly ?

            As for QStandardPaths, you likely want the writable path for AppDataLocation.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Paullux
              wrote on last edited by
              #5

              I do this :

                  QWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
                  QWebEngineProfile* defaultProfile = QWebEngineProfile::defaultProfile();
              
                  defaultProfile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
                  defaultProfile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
                  QHttpPart* header = new QHttpPart;
                  header->setRawHeader("X-Frame-Options", "ALLOWALL");
              
                  defaultProfile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
                  defaultProfile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
              

              but that don't resolve the problem

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                Did you do the paths checks I suggested ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Paullux
                  wrote on last edited by Paullux
                  #7
                      qDebug(qPrintable(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)));
                      qDebug("\n");
                      qDebug(qPrintable(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)));
                  

                  return :

                  C:/Users/paulw/AppData/Local/Paul_WOISARD/FranceTV/cache
                  
                  
                  C:/Users/paulw/AppData/Local/Paul_WOISARD/FranceTV
                  

                  but the folders don't exist in my system

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    I meant before and after setting the path on the default profile.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      Paullux
                      wrote on last edited by
                      #9

                      @SGaist said in Save Cookies in Qt6.2.4 ?:

                      I meant before and after setting the path on the default profile.

                      The problem is existing since i upgrade to Qt6.2.3 or Qt6.2.4, before with Qt5.15.2 ou Qt5.15.6 i havent its problem

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        That I understood very well. Hence I suggested that you compare the values of the cache path before and after you set it on the profile in order to eliminate that as an obvious possible bug.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          Paullux
                          wrote on last edited by
                          #11

                          @SGaist said in Save Cookies in Qt6.2.4 ?:

                          That I understood very well. Hence I suggested that you compare the values of the cache path before and after you set it on the profile in order to eliminate that as an obvious possible bug.

                          in doc i found this :

                              QNetworkAccessManager *manager = new QNetworkAccessManager(this);
                              QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
                              diskCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
                              manager->setCache(diskCache);
                          

                          which save cache but no cookies

                          for your question

                              qDebug("before");
                              qDebug(qPrintable(QWebEngineProfile::defaultProfile()->persistentStoragePath()));
                          
                          ...
                          ...
                          ...
                              qDebug("after");
                              qDebug(qPrintable(QWebEngineProfile::defaultProfile()->persistentStoragePath()));
                          

                          result :

                          before
                          qt.webenginecontext:
                          ...
                          ...
                          ...
                          after
                          C:/Users/paulw/AppData/Local/Paul_WOISARD/FranceTV
                          
                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            Paullux
                            wrote on last edited by
                            #12

                            @Paullux said in Save Cookies in Qt6.2.4 ?:

                            qDebug("before");
                            qDebug(qPrintable(QWebEngineProfile::defaultProfile()->persistentStoragePath()));
                            

                            @SGaist

                            the responses to your question is here :

                                qDebug("before");
                                qDebug(qPrintable(QWebEngineProfile::defaultProfile()->cachePath()));
                                qDebug(qPrintable(QWebEngineProfile::defaultProfile()->persistentStoragePath()));
                                defaultProfile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
                                defaultProfile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
                                qDebug("after");
                                qDebug(qPrintable(QWebEngineProfile::defaultProfile()->cachePath()));
                                qDebug(qPrintable(QWebEngineProfile::defaultProfile()->persistentStoragePath()));
                            

                            reponse :

                            before
                            
                            C:/Users/paulw/AppData/Roaming/Paul_WOISARD/FranceTV/QtWebEngine/OffTheRecord
                            after
                            
                            C:/Users/paulw/AppData/Local/Paul_WOISARD/FranceTV
                            

                            cachePath is never set

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #13

                              Looks like you found the culprit.

                              Can you check with 6.3 ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                Paullux
                                wrote on last edited by Paullux
                                #14

                                @SGaist said in Save Cookies in Qt6.2.4 ?:

                                Looks like you found the culprit.

                                with qt6.2.3 it's the same

                                CachePath: ""
                                StoragePath: "C:/Users/paulw/AppData/Roaming/Paul_WOISARD/FranceTV/QtWebEngine/OffTheRecord"
                                isOffTheRecord: true
                                after
                                CachePath: ""
                                StoragePath: "C:/Users/paulw/AppData/Local/Paul_WOISARD/FranceTV"
                                isOffTheRecord: true
                                

                                perhaps cache size must be define

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  Paullux
                                  wrote on last edited by
                                  #15

                                  the problem with qt6.3.0 is always here

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #16

                                    Then you should check the bug report system to see if there already something about it. If not, please open a new report providing a minimal compilable example that shows that behaviour.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    0
                                    • P Offline
                                      P Offline
                                      Paullux
                                      wrote on last edited by
                                      #17

                                      i created a ticket issue : https://bugreports.qt.io/browse/QTBUG-102133

                                      1 Reply Last reply
                                      0
                                      • P Offline
                                        P Offline
                                        Paullux
                                        wrote on last edited by
                                        #18

                                        its not mean be a bug.

                                        a developer of Qt said me :
                                        Michal Klocek a ajouté un commentaire - Il y a 2 heures
                                        in 6.x series default profile is off the record , you need to create a custom profile and use that.

                                        how to create a profile which is on the record ?

                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #19

                                          Unless I am mistaken you got an answer to that as well on the report.

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          1 Reply Last reply
                                          0
                                          • P Offline
                                            P Offline
                                            Paullux
                                            wrote on last edited by
                                            #20

                                            The Solution is :

                                                QWebEngineProfile *profile = new QWebEngineProfile(QString::fromLatin1("MyApplication.%1").arg(qWebEngineChromiumVersion()));  // unique profile store per qtwbengine version
                                                QWebEnginePage *page = new QWebEnginePage(profile); // page using profile
                                                QWebEngineView *view = new QWebEngineView();
                                            
                                                view->setPage(page);
                                                view->setUrl(AccueilUrl);
                                                view->setZoomFactor(1.2);
                                            
                                                setCentralWidget(view);
                                            
                                            1 Reply Last reply
                                            1

                                            • Login

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