CURL with Cookie problem
Posted: Wed Nov 23, 2005 4:35 pm
Hi,
Trying to do a simple login, where the external site sets a session cookie. I think maybe I have the cookie file path wrong.
I'm on a shared host, linux, do I need to put the full path to the cookie file?
I get a login error page each time,
Thanks,
Josh
Trying to do a simple login, where the external site sets a session cookie. I think maybe I have the cookie file path wrong.
I'm on a shared host, linux, do I need to put the full path to the cookie file?
I get a login error page each time,
Thanks,
Josh
Code: Select all
$url = "http://www.example.com/checklogin.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // SET URL
curl_setopt($ch, CURLOPT_REFERRER, "http://example.com/login.php");
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // FAIL ON ERROR
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // ALLOW REDIRECTS
curl_setopt($ch, CURLOPT_COOKIEFILE, "/home/selltra/public_html/admin/cook"); // COOKIES
curl_setopt($ch, CURLOPT_COOKIEJAR, "/home/selltra/public_html/admin/cook");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN TO VARIABLE
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // TIMES OUT AFTER 4 SEC
curl_setopt($ch, CURLOPT_POST, 1); // SET POST METHOD
curl_setopt($ch, CURLOPT_POSTFIELDS, "username={$config['username']}&password={$config['password']}&Submit2=Submit"); // POST VALUES
$result = curl_exec($ch);
if (! $result) {
echo "Server Connection Problem";
} else {
echo $result;
}