Seems like overkill to me. Just use $this->Session->setFlash('Here is my 
message');  Then do echo $this->Session->flash(); - this not only displays your 
message but also clears it out of the cache.

Jeremy Burns
[email protected]


On 20 May 2010, at 18:16, sami_bk wrote:

> Hi all,
> 
> I am new to CakePHP and i am building a small app.
> i use Session->setFlash('message') to display notifications to the
> users .
> The notification is displayed in the default layout and i delete the
> flash messega from the session using this code
> <code>
> if ($session->check('Message.flash')) {
>    $message = $session->read('Message.flash') ;
>    if($message['message'] != '') {
>        if(is_array($message['message'])) {
>            $text = "" ;
>            foreach ($message['message'] as $mes) {
>                $text = $mes ."<br>" ;
>            }
>        }
>        else $text = $message['message'];
> <div id="flash" class='message2 success'>
>     <p><?php echo $text; ?></p>
> </div>
>        <?php $session->flash() ?>
>    }
> }
> </code>
> My problem is that notification are displayed randomly , ie : it seems
> that the flash message is not deleted from the session.
> PS : using another layout for ajax calls i also delete the flash
> message in this layout.
> 
> Thanks in advance for your help
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to