hello
I have coded this script in order to log me in a form and get a page accessible to the members:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath("cookies.txt"));
curl_setopt($ch, CURLOPT_URL,"http://www.site.org/login.php");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=MY_LOGIN&password=MY_PASS&login=Log In");
curl_exec ($ch); // execute the curl command
$result = curl_close ($ch);
unset($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_COOKIEFILE, realpath("cookies.txt"));
curl_setopt($ch, CURLOPT_URL,"http://www.site.org/member_page.php");
$buf = curl_exec($ch);
if (!$buf) {
echo curl_error($ch);
} else {
echo 'ok';
}
curl_close ($ch);
file_put_contents("out.txt", $buf);
?>
but, in the out.txt, I have the page that guests can view (the login form)
I have 2 cookies in the cookies.txt
thanks for the help