我突然在传递会话变量时遇到问题,我不知道我做错了什么。有关createSession.php 和passingSession.php,请参见下面的测试代码。我可以在 createSession.php 上创建会话,但是当我单击链接以查看会话是否传递给 passSession.php 时,会话现在是空的。
注意: session_start() 是每个页面上的第一件事。没有任何类型的前导空白。
创建会话.php
session_start();
$_SESSION['aID'] = time();
if($_SESSION['aID']==""){
echo "Session is empty. There is a problem creating sessions";
}else{
echo "Session = ".$_SESSION['aID']." There is no problem creating sessions. <a href='passingSession.php'>Click Here</a> to see if sessions are passing ok.";
}
通过Session.php
session_start();
if($_SESSION['aID']==""){
echo "Session is empty. There is a problem passing sessions.";
}else{
echo "Session = ".$_SESSION['aID'].". Passing sessions is ok.";
}