Location: PHPKode > scripts > HTTP Cookie > http-cookie/example.php

	Get some HTTP headers from an URL to test the class, 
	you may also try the variable $http_response_header
	( see PHP manual )

$url = 'http://msn.com';
$headers = get_headers($url);

	Parse cookies from the HTTP headers, call the method
	of the class statically. Note that the 2nd arg for 
	the method is the ORIGINAL URL that returned the 
	HTTP headers.

$cookies = httpcookie::parse($headers, $url);

	Rebuild cookie from the cookies array, call the 
	method of the class statically. Cookie can be
	built for different URLs.

$cookie[0] = httpcookie::build($cookies, $url);
$cookie[1] = httpcookie::build($cookies, 'http://www.msn.com');

	Make a HTTP request with the returned cookie

$options = array(
	'method' => "GET",
	'header' => 
		"Content-type: application/x-www-form-urlencoded\r\n".
		"Cookie: ".$cookie[1]."\r\n"
$context = stream_context_create($options);
$html = file_get_contents('http://www.msn.com', 0, $context);
Return current item: HTTP Cookie