开发者

CakePHP setFlash() weird problem

I want to $开发者_JAVA百科this->Session->setFlash('text'); $this->redirect('page'); but the message is not displayed. I have included both the Session Component and Helper, and the $this->Session->setFlash() in my layout. However, after the redirect, the session doesn't contain any message. If I don't redirect, the message is shown.

So my question is, why isn't the flash message preserved after a redirect? It should be, and this how I've done before, but...it doesn't work now.

Thanks for any help!

Here is my controller code:

if(!$this->Test->__test_possible()){
        $this->Session->setFlash(__('Insufficient data to create test.', true));
        $this->redirect(array('action' => 'index'));
    }

...my layout...(the cake default.ctp)

<?php echo $this->Session->flash(); ?>

and the AppController:

var $helpers = array('Html', 'Form', 'Session', 'Facebook.Facebook');
var $components = array('Session', 'Auth', 'Facebook.Connect');


So we just chased down an odd issue where flash messages would not be displayed, despite having all the proper code. It turned out there was a space character after the closing ?> in the controller file. ಠ_ಠ


Oh darn...I've put Configure::write('Session.cookie', 'Capitalize.me'); in the core.php and it seems he didn't like the dot in the name...now everything works fine. It's frustrating, really. Thanks for your help :)


Flash messages are shown once and then deleted from the cache. You're probably printing it before the redirect, which causes it to not show up on the redirect.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜