[英]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.