cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

cookie jar problem curl and webmin

From: Ben <curlandphp_at_genplan.com>
Date: Fri, 17 Sep 2004 14:56:36 -0700 (PDT)

Hi, I'm trying to get curl to login to webmin. If you don't know what
webmin is, no matter. It runs of of miniserv.pl, and it uses a form based
auth, which then sets a sid cookie. I also know that there is a
"testing=1" cookie set. However no matter how I try I can't get curl to
work with the cookie jar. I've tried many examples, and different
configurations. Always I get:

No cookies
Your browser does not support cookies, which are required for this web
server to work in session authentication mode

I am writing my cookiejar to a folder with 777, but my problem is this:
the file never gets made. So what am I doing wrong? Also, what is the
format of this file, so I can force cookies into place?

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR,
"/home/o/public_html/web_admin/777/cookieFileName");
curl_setopt($ch, CURLOPT_URL,"http://session_login.cgi");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "user=r&pass=p&page=%2F");
curl_setopt($ch, CURLOPT_useragent, "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3");

ob_start(); // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean(); // stop preventing output

curl_close ($ch);
unset($ch);

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE,
"/home/o/public_html/web_admin/777/cookieFileName");
curl_setopt($ch, CURLOPT_URL,"http:///");
curl_setopt($ch, CURLOPT_useragent, "Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3");

$buf2 = curl_exec ($ch);

curl_close ($ch);
//print($buf2);
echo "<PRE>".htmlentities($buf2);

THANK you so much for your help in advance. This is driving me crazy.
-ben

-----
There's no place like 127.0.0.1
http://www.genplan.com
Received on 2004-09-17