Thank you very much ChrisW67! It works.

Perhaps I still misunderstand something, but that's an option for some reason just does not work, cookies Mortal = 1
Qt Code:
  1. #include <QtCore>
  2. #include <QApplication>
  3. #include <QDebug>
  4. #include <QtNetwork>
  5.  
  6. class MyCookieJar : public QNetworkCookieJar
  7. {
  8. public:
  9. QList<QNetworkCookie> getAllCookies() { return allCookies(); }
  10. };
  11.  
  12.  
  13. class CookiesTest : public QObject
  14. {
  15. Q_OBJECT
  16. public:
  17. CookiesTest(QWidget* parent = 0);
  18. void download(QString);
  19.  
  20. private slots:
  21. void replyFinished(QNetworkReply*);
  22. void doAnother();
  23.  
  24. private:
  25. QNetworkAccessManager* manager;
  26. MyCookieJar *cookieJar;
  27. QUrl myUrl;
  28. };
  29.  
  30. CookiesTest::CookiesTest(QWidget* parent)
  31. {
  32. manager = new QNetworkAccessManager;
  33. cookieJar = new MyCookieJar;
  34. manager->setCookieJar(cookieJar);
  35.  
  36. connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
  37. }
  38.  
  39. void CookiesTest::replyFinished(QNetworkReply* reply)
  40. {
  41. qDebug() << reply->readAll();
  42. qDebug() << "getAllCookies: " << cookieJar->getAllCookies();
  43. }
  44.  
  45. void CookiesTest::doAnother() {
  46. manager->get(QNetworkRequest(myUrl));
  47. }
  48.  
  49. void CookiesTest::download(QString url)
  50. {
  51. myUrl = QUrl(url);
  52. QTimer::singleShot(500, this, SLOT(doAnother()));
  53. }
  54.  
  55. int main(int argc, char* argv[])
  56. {
  57. QApplication app(argc, argv);
  58. CookiesTest cookiesTest;
  59. cookiesTest.download("http://test1.ru/test/cookie.php");
  60. cookiesTest.download("http://test1.ru/test/cookie.php");
  61. return app.exec();
  62. }
  63.  
  64. #include "main.moc"
To copy to clipboard, switch view to plain text mode 

Output:
"NUM: []"
getAllCookies: (QNetworkCookie("Mortal=1; expires=Wed, 18-Jul-2029 05:49:51 GMT; domain=test1.ru; path=/test/") )
"NUM: []"
getAllCookies: (QNetworkCookie("Mortal=1; expires=Wed, 18-Jul-2029 05:49:51 GMT; domain=test1.ru; path=/test/") )

But I found another solution to this

Qt Code:
  1. #include <QtCore>
  2. #include <QApplication>
  3. #include <QDebug>
  4. #include <QtNetwork>
  5.  
  6.  
  7. class MyCookieJar : public QNetworkCookieJar
  8. {
  9. public:
  10. QList<QNetworkCookie> getAllCookies() { return allCookies(); }
  11. };
  12.  
  13.  
  14. class CookiesTest : public QObject
  15. {
  16. Q_OBJECT
  17. public:
  18. CookiesTest(QObject *parent = 0);
  19. void download(QString);
  20. void _download(QUrl);
  21.  
  22. private:
  23. QNetworkAccessManager* manager;
  24. MyCookieJar *cookieJar;
  25. QList<QNetworkCookie> cookiesList;
  26. };
  27.  
  28. CookiesTest::CookiesTest(QObject *parent) : QObject(parent)
  29. {
  30. manager = new QNetworkAccessManager;
  31. cookieJar = new MyCookieJar();
  32. manager->setCookieJar(cookieJar);
  33. }
  34.  
  35. void CookiesTest::download(QString url)
  36. {
  37. _download(QUrl(url));
  38. }
  39.  
  40. void CookiesTest::_download(QUrl url)
  41. {
  42. //enters event loop, simulate blocking io
  43. QTimer t;
  44. t.setSingleShot(true);
  45. connect(&t, SIGNAL(timeout()), &q, SLOT(quit()));
  46.  
  47. QNetworkReply *reply = manager->get(QNetworkRequest(url));
  48. connect(reply, SIGNAL(finished()), &q, SLOT(quit()));
  49.  
  50. t.start(5000);
  51. q.exec();
  52.  
  53. if (t.isActive()) {
  54. t.stop();
  55. QByteArray response = reply->readAll();
  56. qDebug() << response;
  57.  
  58. QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
  59. if (reply->error()) {
  60. qDebug()<< "Download failed" << reply->errorString();
  61. } else if (!redirectionTarget.isNull()) {
  62. QUrl newUrl = url.resolved(redirectionTarget.toUrl());
  63. qDebug()<< "Redirect to" << newUrl.toString();
  64. url = newUrl;
  65. // reply->deleteLater();
  66. _download(url);
  67. } else {
  68. qDebug() << "Finish! ";
  69. }
  70.  
  71. reply->deleteLater();
  72.  
  73. } else {
  74. qDebug() << "Timeout";
  75. }
  76.  
  77. cookiesList = cookieJar->getAllCookies();
  78. qDebug() << "getAllCookies: " << cookiesList;
  79. }
  80.  
  81. int main(int argc, char* argv[])
  82. {
  83. QApplication app(argc, argv);
  84. CookiesTest cookiesTest;
  85. cookiesTest.download("http://test1.ru/test/cookie.php");
  86. cookiesTest.download("http://test1.ru/test/cookie.php");
  87. cookiesTest.download("http://test1.ru/test/cookie.php");
  88. return app.exec();
  89. }
  90.  
  91. #include "main.moc"
To copy to clipboard, switch view to plain text mode 

Output:
"NUM: []"
Finish!
getAllCookies: (QNetworkCookie("Mortal=1; expires=Wed, 18-Jul-2029 05:49:51 GMT; domain=test1.ru; path=/test/") )
"NUM: [1]"
Finish!
getAllCookies: (QNetworkCookie("Mortal=2; expires=Wed, 18-Jul-2029 05:49:51 GMT; domain=test1.ru; path=/test/") )
"NUM: [2]"
Finish!
getAllCookies: (QNetworkCookie("Mortal=3; expires=Wed, 18-Jul-2029 05:49:51 GMT; domain=test1.ru; path=/test/") )