Redirect cakephp3中的闪存消息和重定向

Redirect cakephp3中的闪存消息和重定向,redirect,flash,cakephp,cakephp3,Redirect,Flash,Cakephp,Cakephp3,我的一个控制器文件中有以下代码。$this->Flash->error(“错误消息!”); 返回$this->redirect(['controller'=>'users','action'=>'home'])。我的问题是,flash消息没有显示在重定向页面上。有人能帮忙吗?在控制器: $this->Flash->error("error message!"); return $this->redirect(['controller' => 'users', 'actio

我的一个控制器文件中有以下代码。
$this->Flash->error(“错误消息!”);

返回$this->redirect(['controller'=>'users','action'=>'home'])。我的问题是,flash消息没有显示在重定向页面上。有人能帮忙吗?

在控制器:

$this->Flash->error("error message!");
return $this->redirect(['controller' => 'users', 'action' => 'home']);
在home.ctp或layouts/default.ctp中

<?= $this->Flash->render() ?>

**在你的元素/闪光中**


创建错误。ctp如果。不存在

谢谢,但是flash消息仍然没有显示。请将cakephp调试设置为true,清除浏览器缓存,打开开发人员工具,并仔细检查html代码中是否存在flash消息(可能被css隐藏)。flash消息在html中不存在。您是否可以使用success、default和set方法生成flash消息?这些方法都不起作用。当我注释掉
return$this->redirect(['controller'=>'users','action'=>'home'])控制器中的行,flash消息显示在该页面上,但在重定向后不显示。flash消息存储在会话中,确保它工作(即,您正在接收会话cookie,重定向后发送cookie,会话被拾取,等等)具有cakephp 2,并且它也不工作。