Notification Problem After Logging

i am using the pnotify notification in order to display a notification after a successful logging

here is my code




public function actionLogin()

	{

		$model=new LoginForm;


		// if it is ajax validation request

		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')

		{

			echo CActiveForm::validate($model);

			Yii::app()->end();

		}


		// collect user input data

		if(isset($_POST['LoginForm']))

		{

			$model->attributes=$_POST['LoginForm'];

			// validate user input and redirect to the previous page if valid

			if($model->validate() && $model->login()){

				$this->widget('application.extensions.PNotify.PNotify',array( 

					'message'=>'I am really a very simple notification')

				);

				$this->redirect(Yii::app()->user->returnUrl);

				

			}

		}

		// display the login form

		$this->render('login',array('model'=>$model));

	}



when i login, the index page opens but the notification message doesnt appears

it seems that there is a problem with redirect

any idea for this problem??

This is working just as it should. The widget is happening before the redirect happens, so nobody will ever see the popup if used this way. You should probably use something like this after the $model->validate() and $model->login()


Yii::app()->user->setFlash('alert', 'I am really a very simple notification');

and then on the home view, you should have something like


if(Yii::app()->user->hasFlash('alert')) {

    $this->widget('application.extensions.PNotify.PNotify',array('message'=>Yii::app()->user->getFlash('alert')));

}

it works, thank you