views:

19

answers:

1

Hi all,

I am using cakePHP 1.26.
I got this line of code in a Controller:

$this->Session->setFlash('helloworld');

This line of code works perfectly, but I am not sure if there is a variable to
store the message: "helloworld" in cakePHP.

If yes, can I change the name of this variable?
And how can I check out the variable which stored this message?

+2  A: 

If you need a new variable as the session index,you can set a new one:

$this->Session->write($yourname,"helloworld");

And then get it with

$this->Session->read($yourname);

Anyway,I check the source code about session component and find the setFlash function

function setFlash($message, $layout = 'default', $params = array(), $key = 'flash') 
{
    if ($this->__active === true) {
        $this->__start();
        $this->write('Message.' . $key, compact('message', 'layout', 'params'));
    }
}

And the key you want to know is Message.flash.

SpawnCxy
Thank you for the help, Cxy