我正在使用 cakePHP 1.26。
我在控制器中得到了这行代码:
$this->Session->setFlash('helloworld');
这行代码完美运行,但我不确定是否有一个变量来
存储消息:cakePHP 中的“helloworld”。
如果是,我可以更改此变量的名称吗?
以及如何检查存储此消息的变量?
我正在使用 cakePHP 1.26。
我在控制器中得到了这行代码:
$this->Session->setFlash('helloworld');
这行代码完美运行,但我不确定是否有一个变量来
存储消息:cakePHP 中的“helloworld”。
如果是,我可以更改此变量的名称吗?
以及如何检查存储此消息的变量?
如果您需要一个新变量作为会话索引,您可以设置一个新变量:
$this->Session->write($yourname,"helloworld");
然后得到它
$this->Session->read($yourname);
无论如何,我检查了有关会话组件的源代码并找到了setFlash
功能
function setFlash($message, $layout = 'default', $params = array(), $key = 'flash')
{
if ($this->__active === true) {
$this->__start();
$this->write('Message.' . $key, compact('message', 'layout', 'params'));
}
}
而你想知道的关键是Message.flash
。