cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to strip cookies from header responce and save on client machine

From: <info_at_itegic.co.za>
Date: Thu, 10 Sep 2009 11:24:46 -0500 (CDT)

I have following code:

<?php
$ch = curl_init("http://xxxx.imdnet.hop.clickbank.net/");
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

$buffer = curl_exec($ch);
curl_close($ch);

echo ($buffer);
?>

which returns:

HTTP/1.1 301 Moved Permanently Date: Thu, 10 Sep 2009 16:09:18 GMT Server:
Apache Set-Cookie:
p=861971CF5CD0372717109825575495A2D3AE2543850A66DC9F3933A1C8D1CFDE;
Domain=.clickbank.net; Expires=Tue, 09-Mar-2010 16:09:18 GMT; Path=/
Cache-Control: no-store Pragma: no-cache Expires: 0 P3P: CP="ADM OUR IND
COM" Location:
http://xxxx.imdnet.hop.clickbank.net/hop/?CBRehoppp2=http%3A%2F%2Fwww.HowToGetHimBackFast.com%3Fhop%3Dxxxx&vend=imdnet&code=1000000000000000&affi=rednet&hfid=&parms=&key=688C87FC4D8DEF594642913BA11CDE79
Connection: close Content-Type: text/html;charset=ISO8859_1 HTTP/1.1 301
Moved Permanently Date: Thu, 10 Sep 2009 16:09:18 GMT Server: Apache
Cache-Control: no-store Pragma: no-cache Expires: 0 P3P: CP="ADM OUR IND
COM" Connection: close Location:
http://www.HowToGetHimBackFast.com?hop=xxxx Content-Type:
text/html;charset=ISO8859_1 HTTP/1.1 200 OK Date: Thu, 10 Sep 2009
16:09:18 GMT Server: Apache/2.2.13 X-Powered-By: PHP/5.2.10 Set-Cookie:
PHPSESSID=12b27c4401f66621aec02c967769bfbe; path=/ Expires: Thu, 19 Nov
1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, pre-check=0 Pragma: no-cache Accept-Ranges: bytes
Content-Length: 68357 Content-Type: text/html; charset=utf-8

How do I strip the "Set Cookie" part from the header, and actually save
the cookie on the user machine? Also, how can I make the final redirect
"http://www.HowToGetHimBackFast.com?hop=xxxx" to open on client browser as
"http://www.HowToGetHimBackFast.com"?

Thanks,
Peter
Received on 2009-09-10