Reputation: 431
I am working on change password. after i saved the updated or new password i need to display the success message to the user in cakephp.
from change password method,after successful database operation i am redirecting the user to logout method. logout method will delete the session and redirecting user to login method.
How to display the success message in Login method which is set in change password method
Upvotes: 0
Views: 2016
Reputation: 4179
The below code is general and not for cakePHP specific alone.
While redirecting, you need to add some querystring in params. like, if your login.php then
header("location:login.php?response=1");
and you need to read in login.php like this
if (isset ($_GET['response']))
{
if ($_GET['response']=="1")
{
echo "Successfully logged out";
}
}
Upvotes: 0
Reputation: 24969
Have a look at http://book.cakephp.org/view/1313/setFlash. The setFlash function of the Session component was designed for this!
In the original controller action: $this->Session->setFlash('Example message text');
In the view of the other action: echo $session->flash();
Upvotes: 1