1

我怎么能,或者甚至可以改变 curl 写入它的 cookie jar 文件的权限?我正在尝试检索会话 cookie [for an sso plugin] 并且可以写入 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;

?>
4

1 回答 1

1

chmod 不起作用?

chmod($ckfile,0644);

http://ar2.php.net/manual/es/function.chmod.php

于 2012-09-17T18:21:35.547 回答