ngocquynh85
asked on
header . socket and cookies
this is the function I found which to get header of URL.
But I don't know how to use IE-cookies in this.
function get_headers($url,$format=0 )
{
$url_info=parse_url($url);
$port = isset($url_info['port']) ? $url_info['port'] : 80;
$fp=fsockopen($url_info['h ost'], $port, $errno, $errstr, 30);
if($fp)
{
$head = "HEAD ".@$url_info['path']."?".@ $url_info[ 'query']." HTTP/1.0\r\nHost: ".@$url_info['host']."\r\n \r\n";
fputs($fp, $head);
while(!feof($fp))
{
if($header=trim(fgets($fp, 1024)))
{
if($format == 1)
{
$key = array_shift(explode(':',$h eader));
// the first element is the http header type, such as HTTP 200 OK,
// it doesn't have a separate name, so we have to check for it.
if($key == $header)
{
$headers[] = $header;
}
else
{
$headers[$key]=substr($hea der,strlen ($key)+2);
}
unset($key);
}
else
{
$headers[] = $header;
}
}
}
return $headers;
}
else
{
return false;
}
}
But I don't know how to use IE-cookies in this.
function get_headers($url,$format=0
{
$url_info=parse_url($url);
$port = isset($url_info['port']) ? $url_info['port'] : 80;
$fp=fsockopen($url_info['h
if($fp)
{
$head = "HEAD ".@$url_info['path']."?".@
fputs($fp, $head);
while(!feof($fp))
{
if($header=trim(fgets($fp,
{
if($format == 1)
{
$key = array_shift(explode(':',$h
// the first element is the http header type, such as HTTP 200 OK,
// it doesn't have a separate name, so we have to check for it.
if($key == $header)
{
$headers[] = $header;
}
else
{
$headers[$key]=substr($hea
}
unset($key);
}
else
{
$headers[] = $header;
}
}
}
return $headers;
}
else
{
return false;
}
}
ASKER
uhm, I want to use cookie when I get header.
first, I login into a website (by IE),
then I use this function to get header of one page in this site.
But it didn't work as I wish, because this function don't include cookie when I login a website.
:|
first, I login into a website (by IE),
then I use this function to get header of one page in this site.
But it didn't work as I wish, because this function don't include cookie when I login a website.
:|
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To do what exactly?
-r-