Search code examples
cakephpcakephp-1.2

$session->flash()


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?


Solution

  • 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.