Greetings.
What I'am trying to do:
Open trying.php which using curl opens another page on my localtestserver, this page(trying2.php) starts a session, sets a sessionvar.
Then trying.php continues with the next step which is to post(key1 and key2) to trying3.php which displays thoose two keys if sessionvar=1
Now, I first started with fsockopen and sending headers, cookies and it did work, but then I got into the hmm, I want a session also, sure thing I send the sessionid php, php seems to be running the correct session, but no access to sessionvar then I read about curl and it seemed a more organized way of doing this.
The purpose for all this is to logon to a community, check if I got any new messages and then tell me :-) I can see other uses for it but all in all, I realized this was a black gap in my experiences.
Without further gibberish:
trying.php:
<?PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "g:\cookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://192.168.0.3/script/trying2.php");
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, "g:\cookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://192.168.0.3/script/trying3.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "key=username&key2=passwd");
$buf2 = curl_exec ($ch);
curl_close ($ch);
print "<PRE>".htmlentities($buf2);
?>
trying2.php:
<?PHP
session_start();
$_SESSION["sessionvar"]=1;
?>
trying3.php:
<?PHP
session_start();
if($SESSION["sessionvar"]==1)
{
print $POST["key"]."<br>\n";
print $_POST["key2"]."<br>\n";
}
else
{
print "Your not coming from the right link";
}
?>
I'am running php4.3 as a module on Apache1.3, on windowsXP
Now, I realy cant get it to work, from my point of view(which obviously is wrong) it should according to curl >_<
Help appreciated thanks :-)
/C