Home >Backend Development >PHP Tutorial >$_SESSION运行时赋值失败,但debug单步调试却成功运行。

$_SESSION运行时赋值失败,但debug单步调试却成功运行。

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:57:151180browse


在debug调试时,以下代码起作用。能正确赋值。但是如果是在浏览器正常运行,就赋值失败。
打印出:$_SESSION['active_code'] 时,其值等于'3a'.请问是咋回事?调试几个小时了。调试全部正常。但是正常运行就没有值。

       $_SESSION['active_code']['id']=$user_id;        $_SESSION['active_code']['name']=$user['user_name'];        $_SESSION['active_code']['email']=$user['email'];

环境:apache+mysql+php5.4.22


回复讨论(解决方案)

你是怎么打印的?

       $_SESSION['test']='testvv';        $_SESSION['test']['11']='11testvv';        $_SESSION['active_code']['id']=$user_id;        $_SESSION['active_code']['name']=$user['user_name'];        $_SESSION['active_code']['email']=$user['email'];        $_SESSION['active_code']['key']=$this->md5s($user['email'].$user['passwd']);        $this->logs(var_export($_SESSION['active_code'],true));        $this->logs(var_export($_SESSION,true));


打印结果:

[14-05-11 13:46:34] : '3a'
[14-05-11 13:46:34] : array (
  'active_code' => '3a',
  'test' => 'testvv     1',
)

不知道你的 logs 方法里面做了什么

你直接 var_export($_SESSION['active_code']); 看看

问题解决,删除session目录中所有文件后解决。

Statement:
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