为什么取不到SESSION变量的值?该如何解决

WBOY
Release: 2016-06-13 10:01:20
Original
1079 people have browsed it

为什么取不到SESSION变量的值?
在注册SESSION变量的页面是这样写的:
$username   =   $HTTP_POST_VARS[ "username "];
session_register( "username ");

在另一个页面这样判断:
if(!isset($_SESSION[ "username "])   ||   $_SESSION[ "username "]== " ")
{
                print   ( "username   unregistered!
");
                print   ( " Login
");
                die();
}
else   print   ( "username   is   registered!
");


  $HTTP_POST_VARS[ "username "]已经有值了,但是在判断的页面中打印出来的却是username   unregistered!,这是为什么?

PHP的版本是4.3.9,是不是PHP的配置文件还要做什么修改?

------解决方案--------------------
session_start();
$username = $HTTP_POST_VARS[ "username "];
$_SESSION[ 'username '] = $username;
------解决方案--------------------
session_start()了?
------解决方案--------------------
$username = $HTTP_POST_VARS[ "username "];
session_register( "username ");

==>
$_SESSION[ "username "]=$username;
------解决方案--------------------
是不是你的PHP的設置問題?

前面我也遇倒過一次,就是空間商恢復了一次系統,我的session就用不起了,

也不是完全用不起,就是在當前頁賦值,當前頁有效,跨頁就不行了.

過後他重新設置一次就好啦..

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