小弟我用ThinkPHP时的session有关问题

WBOY
Release: 2016-06-13 13:04:59
Original
768 people have browsed it

我用ThinkPHP时的session问题。

为什么用session函数或_SESSION设置的值只在当前方法中可用,换到另一个方法里值就为空了?比如
class UserAction extends Action
{
function login()
{
session('name','admin');
echo session('name');    //这儿可以显示出 admin
}
function rendersession()
{
echo session('name');////访问这个方法的时候就是空的了。
}

用TP的验证码功能时也一样,访问session('verify')值是空的。
------最佳解决方案--------------------
局部作用域,全局的话要用GLOBAL吧
------其他解决方案--------------------

引用:
局部作用域,全局的话要用GLOBAL吧


那楼主自己就看看
------其他解决方案--------------------
自己顶一下,求回答………………
------其他解决方案--------------------
LS的意思我不太明白。初学PHP,能不能说的具体一点?
------其他解决方案--------------------
是PHP的设置问题。把php.ini 里的session.save_path设置一下就好了。
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!