Reputation: 3321
I am using cakePHP v1.26. In the default.ctp file, I got a single of this code in it:
$session->flash();
I came a corss a web site in which the author suggested using this instead:
if($session->check('Message.flash')){
$session->flash();
}
I do not understand what this line of code is doing:
if($session->check('Message.flash')){...}
what is "Message.flash" in this case?
Is "Message.flash" a custom variable or
a built-in varibale which has been predefined in cakePHP?
Upvotes: 2
Views: 4970
Reputation: 2989
In view section for show messages.
$this->Session->flash();
Upvotes: 0
Reputation: 536
For latest cakephp version
if(!($this->Session->check('Message.flash')));
// your code
Upvotes: 0
Reputation: 6571
Note also that contrary to the current manual description, $session->flash() does not echo the result, it just returns it, so you will need to have
echo $session->flash();
in your view.
Upvotes: 1
Reputation:
Message.flash
is the session variable name. It will be defined by cakephp, when you use $this->Session->setFlash('Your message');
from your controller.
if($session->check('Message.flash')){...}
checks, if session Message.flash
, which contains the flash message, exists.
Upvotes: 7