0

I have the below code in one of my controller files.$this->Flash->error("error message!"); return $this->redirect(['controller' => 'users', 'action' => 'home']);.My problem is, flash message is not displaying on the redirected page. Can anyone help?

web_developer
  • 71
  • 1
  • 9
  • Flash messages are stored in the session, make sure it's working (ie that you're receiving the session cookie, the cookie is sent after the redirect, the session is picked up, etc...) – ndm Feb 23 '20 at 23:11
  • Having cakephp 2 and it is not working too. – neobie Jun 09 '21 at 14:47

1 Answers1

1

in controller:

$this->Flash->error("error message!");
return $this->redirect(['controller' => 'users', 'action' => 'home']);

in your home.ctp or layouts/default.ctp

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

** in your Element/Flash**

create error.ctp if . not exists

Salines
  • 5,674
  • 3
  • 25
  • 50