A ver si estas usando cURL, en el manual hay un ejemplo muy claro:
Código PHP:
Ver original<?php
$url = "http://[host][uri]/file1.php"; /*insert desired host and
uri*/
$browser_id = "some crazy browser";
(
CURLOPT_URL=>$url,
CURLOPT_HEADER=>true,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_FOLLOWLOCATION=>true,
CURLOPT_USERAGENT=>$browser_id
);
/*construct the http search pattern for cookies*/
$pattern = "/Set-Cookie:";
$pattern .= "(?P<name>.*?)=(?P<value>.*?); ";
$pattern .= "expires=(?P<expiry_dayname>\w+), ";
$pattern .= "(?P<expiry_day>\d+)-
(?P<expiry_month>\w+)-(?P<expiry_year>\d+) ";
$pattern .= "(?P<expiry_hour>\d+):
(?P<expiry_minute>\d+):(?P<expiry_second>\d+) ";
$pattern .= "(?P<expiry_zone>\w+)/";
$table_string = "
<h1>cookie information table</h1>
<table border='1'>
<tr>
<td>cookie name</td>
<td>value</td>
<td>expiry day</td>
<td>expiry date</td>
<td>expiry time</td>
<td>expiry timezone</td>
</tr>
";
$i=0;
foreach($matches[name] as $cookie_name)
{
$table_string .= "
<tr>
<td>$cookie_name</td>
<td>{$matches[value][$i]}</td>
<td>{$matches[expiry_dayname][$i]}</td>
<td>{$matches[expiry_day][$i]}-
{$matches[expiry_month][$i]}-
{$matches[expiry_year][$i]}</td>
<td>{$matches[expiry_hour][$i]}:
{$matches[expiry_minute][$i]}:
{$matches[expiry_second][$i]}</td>
<td>{$matches[expiry_zone][$i]}</td>
</tr>
";
$i++;
}
$table_string .= "</table>";
echo $table_string;
?>
Saludos.