在从 5.2.17 到 5.3.13 的服务器升级中,我的 $_SESSION 变量不再在页面之间传递。
在第 1 页中,我设置了 $_SERVER["isLoggedIn"] = true 并且在第 2 页中我正在测试,但发现所有 $_SESSION 变量都未设置。
我已经为一个简单的例子减少了代码,如下所示:login.html:
<?php
session_start();
$_SESSION["isLoggedIn"] = true;
$_SESSION['visitorLanguage'] = "en" ;
if ($_SESSION["isLoggedIn"] == true ){
print "<p> Log in successful. </p>";
print "<script>window.location='index.html? lang=".$_SESSION['visitorLanguage']." '</script>";
}
?>
索引.html:
<?
session_start();
echo "Version: ".phpversion();
echo " Session Data: ";
echo "Is logged in: " . $_SESSION["isLoggedIn"]. "<br/>";
echo "Visitor Language: " . $_SESSION["visitorLanguage"];
?>
回报:
Version: 5.3.13 Session Data: Is logged in:
Visitor Language
and in 5.2:
Version: 5.2.17 Session Data: Is logged in: 1
Visitor Language: en