开发者

Can't echo $session->flash(); in CakePHP 1.3.4 - Allowed memory size exhausted

开发者 https://www.devze.com 2023-01-20 02:07 出处:网络
I am using: $this->Session->setFlash(\'gotcha!!\', \'msg_success\'); to write a msg in the Session and try to access it in the file

I am using:

$this->Session->setFlash('gotcha!!', 'msg_success');

to write a msg in the Session and try to access it in the file

\app\views\elements\msg_success.ctp

with the code

if($session->check('Message.flash'))
{
    echo $session->flash();
}

My Phpinfo() says

memory_limit 512M 512M

My app/config/core.php says

Configure::write('Session.save', 'php');
Configure::write('Session.cookie', 'CAKEPHP');
Configure::开发者_JAVA百科write('Session.start', true);

how can that be???


Make sure you have the Session Component and the Session Helper set in the controller. They are not on by default. Although, I would assume it would throw an error, not eat up your memory.

Also, you shouldn't need to do if($session->check('Message.flash')) before using $this->Session->flash(). It should degrade gracefully if no flash message has been set.


in your msg_success.ctp, try just using

<?= $message; ?> 
0

精彩评论

暂无评论...
验证码 换一张
取 消