PHP:所有cookie都不会与cURL一起保存

时间:2016-11-26 07:21:51

标签: php curl cookies

我正在运行以下代码:

 $username = 'alex';
  $loginUrl = 'https://mysite/login';
    $ckfile = '/home/alex/www/storage/logs/cookie.txt';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $loginUrl);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'user=' . $username);
    curl_setopt($ch, CURLOPT_COOKIEJAR,$ckfile);
    curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $status_code = curl_getinfo($ch);
    $resp = curl_exec($ch);
    curl_close($ch);

通过运行return $resp我得到:

HTTP/1.1 302 Found Date: Sat, 26 Nov 2016 07:08:59 GMT Expires: Mon, 02 Aug 1999 00:00:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Set-Cookie: mnproxy=tEiyCofS5YEOiFe; Path=/; Domain=.mysite Location: http://mysite/connect?session=stEiyCofS5YEOiFe&url=menu Vary: Accept-Encoding Content-Length: 352 Content-Type: text/html; charset=iso-8859-1 Set-Cookie: TS0110ac54=01d9c2a5b1932847d951b9185a227fd3d4bfdf23358732abbed5a18dc8b027fc893bda0c4bf3720f253354b709cb68a505ec9cac6dc051e3e792ddf322a734b650b6c33f2e; Path=/; Domain=.mysite

cookie.txt

.auth.mysite        TRUE    /       FALSE   0       TS0110ac54      01d9c2a5b1932847d951b9185a227fd3d4bfdf23358732abbed5a18dc8b027fc893bda0c4bf3720f253354b709cb68a505ec9cac6dc051e3e792ddf322a734b650b6c33f2e

您可以在此处看到没有任何标头保存在其他Cookie TS0110ac54中 我做错了什么?

0 个答案:

没有答案