解决方案 »

  1.   

    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar); //接收cookie
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar); //发送cookie
    $cookiejar 保存cookie的文件,要绝对路径的
      

  2.   


    define('COOKIE_FILE', 'cookie.txt');  $url = "http://example.com/";
    $ch = curl_init();  
    curl_setopt($ch, CURLOPT_URL, $url);  
    curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);    // 接收
    curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);   // 發送
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
    curl_exec($ch);  
    curl_close($ch);