I have a website that needs to send a POST to a website, than read the cookies returned (in an HTTP way – aka Set-Cookie: …)
I tried this code:
<?php
$ch = curl_init('http://www.site.co.il/login.php?do=login');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "datadata");
$a = curl_exec($ch);
curl_close($ch);
but it only loads the website in the browser (without me even writing print($a) !!!) – although it DOES show me ‘connect successfully’ – but ofcorse doesn’t set the cookie.
I basically want to make a proxy-like application, where the cookies received from site.co.il would be stored on the clients machine, but each time it connects to my site, it will grab the cookies and do a POST to site.co.il with them.
Any example of grabbing the Set-Cookie: header from the returned HTTP will be appreciated.
Thank you !
Mihai is right. Here’s some code that does it:
http://us.php.net/manual/en/function.curl-exec.php#92580