【发布时间】:2014-05-16 01:38:03
【问题描述】:
我的网站有一个登录页面,其中显示了世界地图,其中包含每个大陆的悬停链接。点击它会有一个像这样的 HREF 链接:
<a href="setsession.php?c=AU">Australia</a>
setsession.php 只包含这个:
<?php
session_start();
$_SESSION['SelectedCountry'] = htmlspecialchars($_GET["c"]);
header("location:test/index.php");
?>
并且 test/index.php 包含:
<?php
session_start();
echo $_SESSION['SelectedCountry'];
?>
所以我不明白为什么 test/index.php 只显示一个空白页?
【问题讨论】:
-
也许是间距?
header("Location: test/index.php"); -
在 index.php 中尝试 echo ... , print_r($_SESSION);检查是否设置了会话 SelectedCountry
-
它可以转发到 test/index.php。问题是 test/index.php 只显示一个空白页面,而不是回显会话变量。
-
"print_r($_SESSION);"只返回“数组()”
-
您的浏览器是否显示有 PHPSESSID cookie?如果是这样,您能找到与该 cookie id 匹配的会话文件吗?如果是,该会话文件的内容是什么?