CakePHP2.x 中的会话闪烁消息


session flash message in cakephp2.x

我在蛋糕PHP方面没有太多经验。我在控制器中设置了一个会话闪存消息,其语法如下

$this->Session->setFlash(__('Error :: No product found.', true));
i have two function in Controller 
public function details()
{
}
public function add()
{
//my code goes here
$this->request->data['Product']['togo'] == the path where i have to redirect ( details page)
$this->Session->setFlash(__('updated.', true));
$this->redirect($this->request->data['Product']['togo']);
}
Now in the view folder
i dont have add.ctp file
add function manupulate the data and send them to the details page

details.ctp
Noe in the above page i have write below to display
 <?=$this->Session->flash();  // ?>
Issue 
when i click back or next button in the browser that session message will come on the screen

现在,此消息也正确显示在视图文件中。 现在的问题是假设我将单击浏览器的"后退"按钮,然后加载页面并再次显示该消息。如果我按下浏览器的 NEXT 按钮,那么该会话也会显示闪烁消息。我不知道为什么我会遇到这个问题。我还有另一个项目,因为此功能工作正常。请帮助我摆脱这个问题

谢谢你

使用重定向

$this->redirect(array('controller'=>'Controller1','action'=>'view_name'));

或在"返回"按钮中使用hyperlink

你可以试试这个

在控制器闪存消息中,您可以定义所需的消息名称,例如saveorerr,这些消息写入闪存消息,它将自动连接控制器闪存。 您还可以在 Flash 消息中使用数组定义您的自定义 css。

  return  $this->Session->setFlash('Succesfully updated','default',array('class'=>'alert alert-danger'),'saveorerr');
  <?php echo $this->Session->flash('saveorerr');?>