Вот мой http-клиент в php, который отправляет запросы с включенными файлами cookie:
function http_login_client($url, $params = "", $cookies_send = "" ){
// Vars
$cookies = array();
$headers = getallheaders();
// Perform a http post request to $ur1 using $params
$ch = curl_init($url);
$options = array( CURLOPT_POST => 1,
CURLINFO_HEADER_OUT => true,
CURLOPT_POSTFIELDS => $params,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HEADER => 1,
CURLOPT_COOKIE => $cookies_send,
CURLOPT_USERAGENT => $headers['User-Agent']
);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
/// Информация отладки
echo $ response;
var_dump (curl_getinfo ($ ch));
///
// Parse response and read cookies
preg_match_all('/^Set-Cookie: (.*?)=(.*?);/m', $response, $matches);
// Build an array with cookies
foreach( $matches[1] as $index => $cookie )
$cookies[$cookie] = $matches[2][$index];
return $cookies;
} // end http_login_client