【发布时间】:2025-12-24 20:00:14
【问题描述】:
我在 cakephp 方面没有太多经验。 我在控制器中设置了一个会话闪存消息,其语法如下
$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
现在此消息也正确显示在视图文件中。现在的问题是 假设我将单击浏览器的 BACK 按钮,然后加载页面并再次显示该消息。如果我按下浏览器的 NEXT 按钮,那么也会显示该会话闪存消息。 我不知道为什么我会遇到这个问题。我有另一个项目,这个功能工作正常。 请帮助我摆脱这个问题
提前感谢
【问题讨论】:
-
您能否提供更多代码快照?
标签: php variables cakephp cakephp-2.0 session-variables