Page 1 of 1

CURL Cookies

Posted: Thu Apr 07, 2005 12:48 pm
by AngeloDS
I was curious in how to use this?

Code: Select all

<?php
function curl_string ($url,$user_agent,$proxy){

$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, $url); 
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); 
curl_setopt ($ch, CURLOPT_COOKIEJAR, "C:\Program Files\Apache Group\Apache2\htdocs\exile\cookie.txt");
curl_setopt ($ch, CURLOPT_HEADER, 1); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec ($ch);
curl_close($ch);
return $result;

}

$url_page = "http://www.google.com/";
$user_agent = "Mozilla/4.0";
$string = curl_string($url_page,$user_agent);
echo $string;
?>
I found that in the Manual w/ the user example code. I'm curious on how would I add my user/pass stuff to log into a site?

Posted: Thu Apr 07, 2005 4:07 pm
by Weirdan
That depends on how that particular site handles authorization (there's a number of ways to do it).