0

状況:

サイトに入ると、セッション Cookie を設定し、自分自身にリダイレクトします。

問題:

FOLLOW_RELOCATIONおよびでcurl を使用するとCOOKIE_SESSION、リダイレクト後に Cookie が適用されず、最大リダイレクト制限に達したというエラーが発生します。

コード:

curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_INTERFACE, $ip);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

詳細出力:

* About to connect() to www.thesite.org port 80 (#0)
*   Trying x.x.x.254... * Name 'x.x.29.61' family 2 resolved to 'x.x.29.61' family 2
* Local port: 0
* connected
* Connected to www.thesite.org (x.x.x.254) port 80 (#0)
> GET / HTTP/1.1
Host: www.thesite.org
Accept: */*

< HTTP/1.1 302 Moved Temporarily
< Date: Wed, 31 Jul 2013 15:14:05 GMT
< Server: Apache
< cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< pragma: no-cache
< expires: Mon, 17 Jul 1978 05:00:00 GMT
< Last-Modified: Wed, 31 Jul 2013 15:14:05 GMT
< Set-Cookie: JSESSIONID=0A2488FF811CCDAB6A6C95C12AA3F4F8.DB4B9335DF549E1FCF56CF5BD8; Path=/
< Location: http://www.thesite.org/
< Content-Length: 0
< Vary: Accept-Encoding
< Content-Type: text/html
< 
* Connection #0 to host www.thesite.org left intact
* Issue another request to this URL: 'http://www.thesite.org/'
* Re-using existing connection! (#0) with host www.thesite.org
* Connected to www.thesite.org (x.x.x.254) port 80 (#0)
> GET / HTTP/1.1
Host: www.thesite.org
Accept: */*

< HTTP/1.1 302 Moved Temporarily
< Date: Wed, 31 Jul 2013 15:14:06 GMT
< Server: Apache
< cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< pragma: no-cache
< expires: Mon, 17 Jul 1978 05:00:00 GMT
< Last-Modified: Wed, 31 Jul 2013 15:14:06 GMT
< Set-Cookie: JSESSIONID=5A80785B002D8C37F73F798B75A090B4.47EF37A843F03A8253F26BC644; Path=/
< Location: http://www.thesite.org/
< Content-Length: 0
< Vary: Accept-Encoding
< Content-Type: text/html
< 
* Connection #0 to host www.thesite.org left intact
* Issue another request to this URL: 'http://www.thesite.org/'
* Re-using existing connection! (#0) with host www.thesite.org
* Connected to www.thesite.org (x.x.x.254) port 80 (#0)
> GET / HTTP/1.1
Host: www.thesite.org
Accept: */*

etc...

質問は:

私は何を間違っていますか?それを機能させる方法は?もちろん、2回接続して手動で設定することもできましたが、それは私がやりたいことではCURLありませんfile_get_contents()

4

1 に答える 1