【发布时间】:2010-07-13 08:54:30
【问题描述】:
最简单的,如果 file_1.php 包含
<?php
session_start();
$_SESSION["test_message"] = "Hello, world";
header("Location: http://localhost/file_2.php");
?>
并且file_2.php包含
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<body>
<?php
if (!(isset($_SESSION["test_message"])))
echo "Test message is not set";
else
echo $_SESSION["test_message"];
var_dump($_SESSION);
session_destroy();
?>
</body>
</html>
结果是 Test message is not set 并且 var_dump($_SESSION) 返回 null - locally, with Xampp。但是,如果我将这些相同的文件上传到付费托管网站,它就可以工作并且我看到了
Hello, world
array
'test_message' => string 'Hello, world' (length=12)
当我在 Xampp 下查看 PHPinfo 时,它显示 Session Support enabled。我做错了什么?
【问题讨论】: