繁体   English   中英

CakePHP:如何注册会话?

[英]CakePHP: how to register the session?

在PHP5中,代码: session_register("");

我的代码:

function login() {
        // Don't show the error message if no data has been submitted.  
        $this->set('error', false);

        // Production mode. No output. For AJAX
        Configure::write('debug', 0);

        // Does not render the view
        // Others method : $this->render(false, false);
        $this->autoRender = false;

        // The most important : set : debug = 0 and register session
        session_register("");

            $this->Session->write('test',"test1");

                echo $this->Session->read('test');
        }
        return ;
    }

该代码自2001-2002年以来已过时

要将数据存储在会话中,您应该使用:

$this->Session->write('name', 'value');

要获取存储在会话中的数据,请使用:

$data = $this->Session->read('name');

其中name是会话变量名称

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM