2014-01-05 2 views
0

페이지에서 응답을 받으면 응답 데이터를 제공하지만 페이지에서 설정 한 세션의 쿠키를 가져 오려면 어떻게해야합니까? PHP cURL로 어떻게 얻을 수 있습니까?PHP cURL을 사용하여 원격 웹 페이지에서 쿠키를 얻는 방법은 무엇입니까?

+0

'curl_setopt ($ ch, CURLOPT_COOKIEJAR, 'cookies.txt'); curl_setopt ($ ch, CURLOPT_COOKIEFILE, 'cookies.txt'); ' – Eugen

+0

이 도움이 될 수 있습니다. http://stackoverflow.com/questions/247006/save-cookies-for-remote-web-pages –

답변

2

이렇게 할 수있는 방법은 두 가지가 있습니다.

$cookie_file = 'e:/demo/cookies.txt'; 
curl_setopt($ch,CURLOPT_COOKIEJAR, $cookie_file); 
curl_setopt($ch,CURLOPT_COOKIEFILE, $cookie_file); 

컬에서 HTML 소스로 다시 응답 된 헤더 사용 :

쿠키 파일을 사용하여.

curl_setopt($curl_connection, CURLOPT_HEADER, true); 
// this is returning the http response header along with html 

두 번째 예의 경우 Set-Cookie: 헤더 아래에 쿠키가 있습니다.

그런데 말다툼을 어떻게 처리해야하는지 알고 있다고 생각합니다. 여기에 없다면 few helps입니다.

관련 문제