curl-and-php
How to pass set-cookie header to browser
Date: Sun, 13 Sep 2009 08:20:26 -0500 (CDT)
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
Received on 2009-09-13