开发者

PHP Curl, error: Browser must support session cookies?

I am getting an error on the browser saying:

HTTP/1.1 500 Internal Server Error Date: Fri, 06 May 2011 20:25:28 GMT Server: IBM_HTTP_Server/6.0.2.43 Apache/2.0.47 (Unix) $WSEP: Set-Cookie: JSESSIONID=0000HpGRXpuwrdY_u0k-ecHKAFK:14ekdcv70; Path=/ Connection: close Transfer-Encoding: chunked Content-Type: text/html;charset=ISO-8859-1 Content-Language: en Error 500: Browser must support session cookies.

How to solve this problem?

here what I did:

session_start();

$postData = http_build_query($_GET);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "\BuiltinObjectToken-VerisignClass3开发者_Go百科PublicPrimaryCertificationAuthority.crt");
    curl_setopt($ch, CURLOPT_URL, "https://zzzzzz.zzzzz.co.uk/zzz/zzzz/" . $form_link );
    curl_setopt($ch, CURLOPT_POST, 1 );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postDataCapcha);
    curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
    curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $PagaeCapcha = curl_exec($ch); 

exit($PagaeCapcha);


Set-Cookie: JSESSIONID=0000HpGRXpuwrdY_u0k-ecHKAFK:14ekdcv70; Path=/ 

This is the response header which initially sets a session cookie. This one will not get stored in your cookiefile jar. It's a temporary cookie, and you are throwing it away.

You will have to first issue a requesting request that points to the e.g. homepage. And only afterwards send the actual data request to the desired endpoint /zzz/zzzz/.


Problem is that you're sending the name of the session that YOUR copy of PHP has created. This is almost certainly not the name of the session that the .co.uk server has created. So it's seeing that as your "browser" not supporting cookies - it tries to set a session cookie named 'JSESSIONSID', but you send back a cookie named 'PHP_SESSID' (or whatever).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜