我正在尝试跨子域分享Sessions,这也是他们自己的帐户。
www.example.com
kb.example.com
我用来执行此操作的代码是
<?php
ini_set("session.cookie_domain", ".example.com");
// this was setting the session file to 0644 even though i was attempting 0777
//ini_set('session.save_path', '0;777;' . session_save_path());
session_start();
// this modifies the session files permissions correctly
$path = session_save_path() . '/sess_' . session_id();
chmod($path, 0777);
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
$_SESSION['test'] = 1;
echo session_id();
?>
如果我在www.example.com
上运行此代码,可以很好地阅读会话信息,如果我在kb.example.com
上运行相同的代码,我将收到以下错误
PHP Warning: chmod(): Operation not permitted in /home/kbexample/public_html/test.php on line 8
PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
如何在这些域中读取/写入会话数据?为什么我不能读取文件,即使它是0777?