- 论坛徽章:
- 1
|
session问题,更奇怪的问题啊
我觉得是你的环境问题,我做了两个测试页面,和我预期的一样在运行
- <?php
- // 1.php
- session_start();
- $_SESSION['testsess'] = 'test';
- header('Location: 2.php');
- ?>;
复制代码
- <?php
- // 2.php
- session_start();
- echo $_SESSION['testsess'];
- ?>;
复制代码
然后我用telnet请求1.php,如下:
cat@DCUnit3:cat$ telnet 192.168.221.150 80
Trying 192.168.221.150...
Connected to 192.168.221.150.
Escape character is '^]'.
GET /dev/1.php HTTP/1.0
HTTP/1.1 302 Moved Temporarily
Connection: close
Date: Tue, 07 Dec 2004 07:13:28 GMT
Server: Microsoft-IIS/6.0
Content-type: text/html; charset=gb2312
X-Powered-By: PHP/4.3.8
Set-Cookie: PHPSESSID=ba3bbec4d25a9167f166a099a0ae383c; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: 2.php
Connection closed by foreign host.
可以看到PHPSESSID正确的输出了,如果是浏览器的话,会在客户端产生Session Cookie,然后再由Location: 2.php将浏览器转入到2.php上去,这和用户直接请求并无不同。
另外,我也查看了session文件,不会产生两个文件,只会有一个有内容的文件。
所以肯定是你的环境问题。 |
|