다른 웹 페이지에서 내용을 가져와야하는 PHP 응용 프로그램이 있으며, 읽고있는 웹 페이지에 쿠키가 필요합니다.원격 웹 페이지의 쿠키 저장
쿠키 (http://groups.google.com/group/comp.lang.php/msg/4f618114ab15ae2a)가 있으면이 전화를하는 방법에 대한 정보를 찾았지만 쿠키를 생성하는 방법이나 쿠키가 저장되는 방법을 모릅니다.
예를 들어, 나는 다음을 수행 wget을 통해이 웹 페이지를 읽기 :
wget --quiet --save-cookies cookie.file --output-document=who.cares \
http://remoteServer/login.php?user=xxx&pass=yyy
wget --quiet --load-cookies cookie.file --output-document=documentiwant.html \
http://remoteServer/pageicareabout.html
... 내 질문에 내가 PHP에서 '--save-쿠키'비트합니까 방법입니다 그래서 후속 PHP의 stream_context_create에서 쿠키를 사용할 수 있습니다/file_get_contents 차단 :
$opts = array(http'=> array(
'method'=> "GET",
'header'=>
"Accept-language: en\r\n" .
"Cookie: **NoClueAtAll**\r\n"
)
);
$context = stream_context_create($opts);
$documentiwant = file_get_contents("http://remoteServer/pageicareabout.html",
0, $context);