How do I save cookies with Qt?

前端 未结 3 792
臣服心动
臣服心动 2021-01-01 05:20

I am trying to save cookies that are produced by my app to disk location such as C:\\Users\\Username\\AppData\\Local\\MyCompany\\MyApp. I have implemented a web

3条回答
  •  春和景丽
    2021-01-01 05:49

    You will need to subclass QNetworkCookieJar and in that class you should implement your own persistent storage.

    class MyNetworkCookieJar : public QNetworkCookieJar {
    
    public: 
    
    bool saveCookiesToDisk() {
    // .. my implementation
    return true; // if i did
    }
    
    bool loadCookiesFromDisk() {
    // .. load from disk
    return false; // if unable to.
    }
    }
    

    The sample application from Qt project implements a persistent cookie store, it could be a good starting point for you: http://qt.gitorious.org/qt/qt/trees/4.8/demos/browser

    look at cookiejar.h and cookiejar.cpp

提交回复
热议问题