CURL Cookies

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AngeloDS
Forum Newbie
Posts: 6
Joined: Wed Apr 06, 2005 9:20 am

CURL Cookies

Post 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?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

That depends on how that particular site handles authorization (there's a number of ways to do it).
Post Reply