I am working through the "Cake PHP 1.开发者_JAVA技巧3 Application Development Cookbook," CH. 1 -- the section "Allowing logins with username or email".
The problem is that when you login using your email, even if you are successful, the flash message for an "Invalid Account" has already been set by the Auth component. So I need to unset that message in the login action of the users controller, after a successful login by email. Setting it to the empty string does not work, as an empty orange bar is displayed.
Is there a way to completely unset a flash message?
Thanks, Jonah
To unset a flash message with CakePHP 1.3, using the SessionComponent
within a controller:
$this->Session->delete('Message.flash');
i use this instead of above code.
$this->Session->delete('Message.auth');
If you're worried about the message persisting in memory after the Session->flash() function has been called in the view, then you needn't. Inside the flash() function, the message is getting cleared out with the this call:
CakeSession::delete('Message.' . $key);
So you shouldn't need to delete the message yourself.
精彩评论