How can I, or is it even possible to alter the permissions that curl writes it’s cookie jar file with? I’m trying to retrieve session cookies [for an sso plugin] and can get the cookie file written, but when I go to read the file the permissions are 600 & I can’t open the file to parse the content…. basically I need to set the permissions to 644.
<?php
$username = 'xxxxxxxxxxx';
$password = 'xxxxxxxxxxxxxxx';
$ckfile = tempnam("./", "MOODCOOKIE_");
//set POST variables
$url = 'http://domain.com/login/index.php';
$fields_string = 'username='.$username.'&password='.$password.'&rememberusername=1&Login';
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch,CURLOPT_AUTOREFERER, true );
//execute post
$content = curl_exec($ch);
$response = curl_getinfo( $ch );
echo '<br /><pre>';
print_r($response);
echo '<br /></pre>';
$file_handle = fopen($ckfile, "r");
while (!feof($file_handle)) {
$line = fgets($file_handle);
echo $line.'<br />';
}
fclose($file_handle);
//close connection
curl_close($ch);
return $yourcookie;
?>
chmod doesnt works?
https://www.php.net/manual/es/function.chmod.php