How to pass set-cookie header to browser

[email protected]
Newsgroups gmane.comp.web.curl.php
Message-ID <[email protected]>
Hi,

I have the following code:
<?php
	$cookie_file=dirname(__FILE__).'/cookie.txt';
	$url='http://rednet.imdnet.hop.clickbank.net/';

	$ch = curl_init();
	curl_setopt($ch,CURLOPT_URL,$url);
	curl_setopt($ch,CURLOPT_TIMEOUT,30);
	curl_setopt($ch,CURLOPT_MAXREDIRS,4);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
	curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
	curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file);
	curl_setopt($ch,CURLOPT_COOKIEFILE,$cookie_file);
	curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
	curl_setopt($ch, CURLOPT_ENCODING, '');
	curl_setopt($ch, CURLOPT_HEADER, TRUE);
	curl_setopt($ch, CURLOPT_NOBODY, TRUE);

	$header = curl_exec($ch);
	$result=curl_getinfo($ch);

	curl_close($ch);

	header('Location: '.substr($result['url'], 0, strpos($result['url'],
'?hop=')))

?>

The aim of code is to get the final url, strip ?hop= part from url, and
redirect browser to that url. It works fine, and redirects to the correct
url. However, its not passing the cookie information to the browser.
Cookie info is saved in cookie.txt file. How do I pass that cookie data to
the browser?

Thanks,
Peter



_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.