免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1935 | 回复: 8
打印 上一主题 下一主题

session困惑了我N天了,怎么办啊? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-06-02 23:31 |只看该作者 |倒序浏览
//security.inc
<?
session_register("user_id";
session_register("user_password";
session_destroy();
if ($user_id==""||$user_password==""
   {
         echo "出错!":
         exit();
   }
?>;     
//certain.php
<?
   session_start();
   session_register("user_id";
   session_register("user_password";
   $user_id=$user_name;
   $user_password=$passwd;
   header("location:login.php";
?>;
//login.php
<?
   require("security.inc";
?>;
<html>;
<body>;
......
<a href="search.php">;test</a>;
......
</body>;
</html>;
//search.php
<?
   require("security.inc";
?>;
<html>;
</html>;
到了search.php后,$user_id和$user_password就不能被传过来了,这是怎么回事啊?我也修改了/etc/php.ini中的registry_globals=on.请帮忙啊??

论坛徽章:
0
2 [报告]
发表于 2003-06-03 08:24 |只看该作者

session困惑了我N天了,怎么办啊?

在security.php中也要写session_start()才行吧,如果不写,要在httpd.conf中配置session_auto_start = On
另外,确信你的浏览器支持cookie,否则,你要传递SESSIONID

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
3 [报告]
发表于 2003-06-03 09:15 |只看该作者

session困惑了我N天了,怎么办啊?

你注意到php manual里的一段话没有?

If register_globals is disabled, only members of the global associative array $_SESSION can be registered as session variables. The restored session variables will only be available in the array $_SESSION.

Use of $_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended for improved security and code readablity. With $_SESSION, there is no need to use the session_register(), session_unregister(), session_is_registered() functions. Session variables are accessible like any other variables.

看看是不是这个原因?

论坛徽章:
0
4 [报告]
发表于 2003-06-03 10:00 |只看该作者

session困惑了我N天了,怎么办啊?

我想你的login.php的文件时,那二个变量应该也没有传过去吧

论坛徽章:
0
5 [报告]
发表于 2003-06-03 11:23 |只看该作者

session困惑了我N天了,怎么办啊?

多谢各位会贴,我该了/etc/php.ini中的session.auto_start = 1,session_register=on,可是还是不行啊?
login.php是传上来了的!
继续帮忙,浏览器用的是Mozilla(Linux).

论坛徽章:
0
6 [报告]
发表于 2003-06-05 22:50 |只看该作者

session困惑了我N天了,怎么办啊?

加入:   

setcookie('PHPSESSID', $PHPSESSID, time()+(60*60*15));

论坛徽章:
0
7 [报告]
发表于 2003-06-06 00:15 |只看该作者

session困惑了我N天了,怎么办啊?

session_register("user_id";
session_register("user_password";
session_destroy();

请问这是什么意思?注册了SESSION变量以后立即又删除?那有什么用??

论坛徽章:
0
8 [报告]
发表于 2003-06-06 08:02 |只看该作者

session困惑了我N天了,怎么办啊?

的确比较奇怪,把那行注释了。

论坛徽章:
0
9 [报告]
发表于 2003-06-06 23:34 |只看该作者

session困惑了我N天了,怎么办啊?

多谢!我去试试现
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP