cakephp logo

Not getting setFlash messages in CakePHP 1.2

If your not observing your $this->Session->setFlash messages, make sure you have the following code present in your layout or view ...

Show Plain Text
PHP code
  1. <?php
  2. if ($session->check('Message.flash')) {
  3.   $session->flash();
  4. }
  5. ?>

This caught me out one time after editing the default.ctp layout and accidentally removing the $session->flash() line.

Filed under: Cakephp  Tags: Setflash

12 Responses to “Not getting setFlash messages in CakePHP 1.2”

Gr8 Solution..

No problem, Glad it helped.

tnx men was looking an whole day to let this work and then finnally you mentions this (the only one who's mentioned it ) tnx a lot men

thaks a lot man...cheers..!!

it really works. thanks

Very helpful!

I searh about this topic a whole day ..., thank to you ..., Good Bless You

Thanks, thats a gr888 help..

Very helpful! thk!

Really good help. See these small things you will never find when you are learning anything by yourself. Thanks a lot. Only the developers who were pulling their hairs will know that how much it helped :)

If it doesn't work, add echo before $session->flash();

Perfect Article. You saved me Man. Thanks for sharing such a nice article. really Helpful.

Sorry, comments have been closed for this post.
(default) 11 queries took 3 ms
NrQueryErrorAffectedNum. rowsTook (ms)
1DESCRIBE `posts`17171
2DESCRIBE `comments`11111
3DESCRIBE `tags`220
4DESCRIBE `categories`220
5DESCRIBE `posts_tags`220
6DESCRIBE `categories_posts`220
7SELECT `Post`.`id`, `Post`.`url`, `Post`.`title`, `Post`.`icon`, `Post`.`metadesc`, `Post`.`metakeys`, `Post`.`categories`, `Post`.`tease`, `Post`.`body`, `Post`.`private_body`, `Post`.`created`, `Post`.`modified`, `Post`.`status`, `Post`.`allow_comments`, `Post`.`tags`, `Post`.`hitcount`, `Post`.`hitcount_rss` FROM `posts` AS `Post` WHERE `Post`.`url` = 'not-getting-setflash-messages-in-cakephp-1-2' LIMIT 1110
8SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`body`, `Comment`.`author`, `Comment`.`url`, `Comment`.`email`, `Comment`.`ip`, `Comment`.`status`, `Comment`.`junk_score`, `Comment`.`created`, `Comment`.`modified` FROM `comments` AS `Comment` WHERE `Comment`.`status` = 2 AND `Comment`.`post_id` = (9) 12120
9SELECT `Tag`.`id`, `Tag`.`tag`, `PostsTag`.`post_id`, `PostsTag`.`tag_id` FROM `tags` AS `Tag` JOIN `posts_tags` AS `PostsTag` ON (`PostsTag`.`post_id` = 9 AND `PostsTag`.`tag_id` = `Tag`.`id`) 110
10SELECT `Category`.`id`, `Category`.`category`, `CategoriesPost`.`post_id`, `CategoriesPost`.`category_id` FROM `categories` AS `Category` JOIN `categories_posts` AS `CategoriesPost` ON (`CategoriesPost`.`post_id` = 9 AND `CategoriesPost`.`category_id` = `Category`.`id`) 111
11UPDATE `posts` AS `Post` SET `Post`.`hitcount` = Post.hitcount + 1 WHERE `Post`.`id` = 910