views:

65

answers:

1

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.

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
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
Correct, $this->Session in the Component is used to call Session component, while $this->Session in View is calling Session helper.
Nik
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