- fclose: documentation ( source)
- fwrite: documentation ( source)
- fopen: documentation ( source)
- file_exists: documentation ( source)
<?php
$cookieFile = "cookies.txt";
if(!file_exists($cookieFile)) {
$fh = fopen($cookieFile, "w");
fwrite($fh, "");
fclose($fh);
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://localhost/mysite/test.php?data=hello',
CURLOPT_HEADER => false,
CURLOPT_COOKIESESSION=>true,
CURLOPT_COOKIEFILE => $cookieFile,
CURLOPT_COOKIEJAR => $cookieFile
));
$resp = curl_exec($curl);
curl_close($curl);
echo $resp;
?>