Curl — проблема с cookie (заголовок не устанавливает cookie для браузера)

Я использую этот скрипт:

 <?php
/*
This script is an example of using curl in php to log into on one page and
then get another page passing all cookies from the first page along with you.
If this script was a bit more advanced it might trick the server into
thinking its netscape and even pass a fake referer, yo look like it surfed
from a local page.
*/

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookieFileName");
curl_setopt($ch, CURLOPT_URL,"http://www.myterminal.com/checkpwd.asp");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "UserID=username&password=passwd");

ob_start();      // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean();  // stop preventing output

curl_close ($ch);
unset($ch);

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookieFileName");
curl_setopt($ch, CURLOPT_URL,"http://www.myterminal.com/list.asp");

$buf2 = curl_exec ($ch);

curl_close ($ch);

echo "<PRE>".htmlentities($buf2);
?>

И когда я запускаю этот скрипт, я получаю это:

HTTP/1.1 429 Cache-Control: private Content-Length: 54 Content-Type: text/html Server: Microsoft-IIS/7.5 Set-Cookie:uzytkownikl=0908098d7a1e8c36969eaf195536d47915eaaac1a8392cac3b2776e9290e9
888;Path=/;Domain=example.pl Set-Cookie: ASP.NET_SessionId=4jrpnvd3xd2g1zayp5kss443; path=/; HttpOnly X-AspNetMvc-Version: 4.0 X-Powered-By: ASP.NET X-Powered-By: ARR/2.5 X-Powered-By: ASP.NET Date: Thu, 18 Sep 2014 20:34:29 GMT The error module does not recognize this error.

Set-cookie не работает. Ни один из файлов cookie не был добавлен в браузер.
Есть ли способ это исправить? Мне нужно войти в систему на одной странице, а затем получить другую страницу, пропуская все файлы cookie с первой страницы.

0

Решение

я думаю, что ваш / tmp / файл не имеет разрешения на запись
сделать его доступным для записи, тогда он будет отправлять куки

0

Другие решения

Других решений пока нет …