I am writing a CakePHP app but it doesn't seem to be showing flash() messages on any of the pages.
I am using $this->Session->setFlash();
to set flash() messages and using $this->Session->flash()
in my default template, as well as $this->Session->flash('auth')
on the login and registration pages but they don't show the validation errors etc.
views:
65answers:
1
A:
In your views & layouts, you're looking for the session helper, not the session component that you're trying to use. In controllers/components, you use the session component and reference it as $this->Session
. In your layouts and views, you use the session helper and reference it simply as $session
. e.g. $session->flash();
More about the session helper can be found in the documentation.
Rob Wilkerson
2010-07-19 23:17:17
Thank you. Actually, you can use both with the 1.3 release, but the problem was that I forgot to echo the flash() to the screen.That link showed me that I was supposed to do that.
chustar
2010-07-19 23:25:43
Correct, $this->Session in the Component is used to call Session component, while $this->Session in View is calling Session helper.
Nik
2010-07-20 05:31:23
Fair enough. You didn't mention a version and most of my work is still in 1.2 so I naturally gravitate in that direction. :-)
Rob Wilkerson
2010-07-20 11:10:39