Hey I am using curl to access a page that has iframes, and uses cookies. I need to access the index.php grab a cookie by its name then go to a page in the iframes with the cookie set in the header, or something like that. can anyone help?
Will this help? http://curl.haxx.se/rfc/cookie_spec.html or this http://www.daniweb.com/forums/thread78356.html#
I made this function for you try it : function get_content($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)'); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); //saved cookies curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $string = curl_exec ($ch); curl_close ($ch); return $string; } PHP:
$ch = curl_init('http://www.google.com/'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // get headers too with this line curl_setopt($ch, CURLOPT_HEADER, 1); $result = curl_exec($ch); // get cookie preg_match('/^Set-Cookie:\s*([^;]*)/mi', $result, $m); parse_str($m[1], $cookies); var_dump($cookies); PHP: