我怎么能,或者甚至可以改变curl写入cookie jar文件的权限?我正在尝试检索会话cookie [用于sso插件]并且可以写入cookie文件,但是当我去阅读文件时,权限是600&我无法打开文件来解析内容....基本上我需要将权限设置为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;
?>