使用PHP会话保存变量时出现问题



我在保存会话变量时似乎遇到了问题。我尝试使用session_status(),它输出为2。也许有一些方法可以检查会话为什么保存不正确?

Page1.php

<?php
session_start();
?>
<body>
<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>
<a href="Page2.php">Click Me</a>
</body>

Page2.php

<?php
session_start();
?>
<body>
<?php
print_r($_SESSION);
?>
</body>

原来我必须添加一个tmp文件夹并添加一个php_flag output_buffering on

最新更新