QT 获取服务器返回的Set-cookie

  • 设置槽函数
        QNetworkAccessManager *net_manager_ = new QNetworkAccessManager(this);
        connect(net_manager_, SIGNAL(finished(QNetworkReply*)), receiver, SLOT(onNetworkFinished(QNetworkReply*)));

  • 其中cookies即为服务器返回的cookie
void LoginForm::onNetworkFinished(QNetworkReply * reply)
{


    QString jsonData = reply->readAll();
        QVariant variantCookies = reply->header(QNetworkRequest::SetCookieHeader);
        QList cookies = qvariant_cast >(variantCookies);

        QNetworkCookie cookie=cookies.at(0);

        QString DataAsString =cookie.toRawForm();//toRawForm方法是转换为QByteArray
        qDebug() <

你可能感兴趣的:(QT 获取服务器返回的Set-cookie)