Controller::flash() includes a redirect

Session::setFlash() adds the message to the session and will display it in
the appropriate place when a layout is rendered. 

If you want to immediately redirect with setFlash, you should add the
redirect statement separately. Something like this:

        $this->Session->setFlash('Invalid selection.');
        $this->redirect(array('action'=>'index'), null, true);

If you use Session::setFlash() you should also make sure that you have
provided a place in your layout to display the message.  Something like
this:

        <?php if($session->check('Message.flash')) $session->flash(); ?>

Hope this helps.

rhett waldock
clearsite new media

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Christopher E. Franklin, Sr.
Sent: Tuesday, March 06, 2007 4:29 PM
To: Cake PHP
Subject: Re: setFlash()


Sorry, I did find setFlash, it is in the Session component.  So, you
can use the controller to do a flash or the session but, I think you
have to do $this->Session->setFlash or $this->SessionComponent-
>setFlash

I am still using 1.1.xxxx

On Mar 6, 2:08 pm, "ericc59" <[EMAIL PROTECTED]> wrote:
> I am getting an error with setFlash on a new installation with version
> 1.2.0.4451alpha.
>
> Here is the code calling it:
> $this->setFlash("You have successfully been logged in.");
>
> and I get this error:
> Fatal error: Call to undefined method UsersController::setFlash() in
> users_controller.php on line 211
>
> Is there something I am missing?






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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