让我感到奇怪的是,“PHPSESSID”没有改变,所以会话已经设置好了。
当我删除cookie并刷新页面时,“PHPSESSID”会发生变化。
这是我的代码:
if (!is_writable(session_save_path())) {
echo 'Session path "'.session_save_path().'" is not writable for PHP!';
} // checking if its the problem but it's not.
if (!isset($_SESSION['started'])) {
// i've tried with session_status() == PHP_SESSION_NONE but with the
// same result
session_start();
echo 'session started<br>';
$_SESSION['started'] = 1;
$_SESSION['test']= 'TestValue<br>';
}
echo ($_SESSION['test']) ?? 'Nothing Found<br>';
输出总是:
session started
TestValue
PHP版本:7.1.13
系统:Ubuntu 16.04