入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

关于$_SESSION[]

创建时间:2012-03-15 投稿人: 浏览次数:6291

在我的程序里:

               在 public function logingoAction() 中有这么几行程序:            

                    session_start(); //开启会话

                           session_unset();//删除会话
       session_destroy();
       session_register("password");//创建会话变量,保存密码
       $HTTP_SESSION_VARS["passowrd"]=$password1;
       session_register("username");//保存用户名
       $HTTP_SESSION_VARS["username"]=$username1;

          在 public function changepasswordgoAction()中要用$_SESSION["username"]中的值,如下:

             $where=$db->quoteInto("username=?",$_SESSION["username"])
        .$db->quoteInto("and password=?",$oldpassword);


 结果,无论在怎么试验,$_SESSION["username"]中都没有值。

后来,发现亮点错误:

一:需要在public function changepasswordgoAction()中开启会话,即,添加:  session_start();如果很多的Action()中用到了会话变量,我们可以在 public function init()中统一开启会话:即把 session_start(); 放在 public function init()函数中。

二:在public function logingoAction()中,把   $HTTP_SESSION_VARS["passowrd"]=$password1; $HTTP_SESSION_VARS["username"]=$username1;

改为:

  $_SESSION["passowrd"]=$password1; $_SESSION["username"]=$username1;

程序可以成功执行了。




声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
  • 上一篇:没有了
  • 下一篇:没有了
未上传头像