session中值为0将转换为false的有关问题

WBOY
Release: 2016-06-13 11:12:15
Original
813 people have browsed it

session中值为0将转换为false的问题
A页面

<br />/*判断SESSION是否开启*/<br />        if(session_id() ? false : true)<br />            session_start();<br />$_SESSION['uid'] = 0;<br />$_SESSION['username'] = 'admin';<br />
Copy after login


B页面
<br />/*判断SESSION是否开启*/<br />        if(session_id() ? false : true)<br />            session_start();<br />print_r($_SESSION);<br />var_dump($_SESSION['uid']);<br />
Copy after login

执行A页面后再执行B页面,B页面输出
<br />Array ( [uid] => [username] => admin ) bool(false)<br />
Copy after login


Cookie作用域正常,且本地测试不存在跨域问题。两个页面session_id一致,页面编码一致。A页面中的$_SESSION['uid']是int(0),B页面却是bool(false),这个问题困惑两天,不知道哪里出了问题,请高人赐教


------解决方案--------------------
我运行你的代码是正常的
------解决方案--------------------
有些框架会自己session_start的,找找有没有
------解决方案--------------------
很显然,你的框架对 $_SESSION['uid'] 做了判断、处理
既然是“小众”的,你就慢慢找吧
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!