开发者

CakePHP: how to register the session?

In PHP5, the cod开发者_StackOverflowe: session_register("");

my code:

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 ;
    }


This code is outdated since 2001-2002

To store the data in the session you should use:

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

To get the data stored in the session use:

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

Where name is the session variable name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜