[询问]php中关于session的一点疑问解决方法

WBOY
Release: 2016-06-13 10:08:22
Original
736 people have browsed it

[询问]php中关于session的一点疑问
我在网上看到php session的用法。
1.php
session_start();
$_SESSION[‘passwd’] = "mynameislikui";

2.php
session_start();
echo $_SESSION[‘passwd’];

我用浏览器从1.php跳到2.php是能正常显示的。但是我用客户端写一个httprequest却有点问题。
我的测试是这样的,访问1.php返回的response中我发现http头中多了
PHPSESSID=7e66f1f846b9645d4269569eccdc29f6
这个值,于是将这个值加入到访问2.php的request的头部。但结果是什么都没有返回。
我不知道我这样的方式对不对,但我感觉浏览器中也没做什么特别的处理,为何就能正常的显示呢?
不知道我有没有把问题说清楚?请高人解惑

------解决方案--------------------
你想做什么呢?学习php里的session的用法? 

$_SESSION[‘passwd’] = "mynameislikui";
是错的,应该是 

$_SESSION['passwd'] = "mynameislikui";


------解决方案--------------------
应该是可以的。
可以用程序取得响应信息头, 然后下次发送时把这个信息也写在头部。

要注意, 哪果sesssionid 存的是cookie, 发送时也要构造在cookie里。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!