Flash Message Not Displaying After Redirection

This thing is really driving me crazy. I am working on a project from 6 months, Everythign working fine but now Flash message not display after Rediction. It is working fine on localhost. But when i deploy it on server, i don’t what happened to it and it does not show flash message.

Controller





        public function actionCreateInventoryItem()

	{

		$errors = '';

		$model=new Imei('inventory_imei');

	

		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);

		

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

		{

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

	

			//saving data to imei and imei history

			if($model->save()){

				

				yii::app()->user->setFlash('success', 'Item created successfully');

				$this->redirect('createinventoryitem', array( 'id'=> $id ));

			}

			else{

				foreach ($model->getErrors() as $error){

					$errors .= $error[0]."<br>";

				}

				yii::app()->user->setFlash('error', $errors);

			}

		}

	

		$this->renderPartial('popup_inv_item',array(

				'model'=>$model,

	

		),false, true);

	}




View






        <?php

	    foreach(Yii::app()->user->getFlashes() as $key => $message) {

	        echo '<div class="flash-' . $key . '">' . $message . "</div>\n";

	    }

	?>


	<?php echo $form->errorSummary($model); ?>




Flash messages shows if i disable the redirection. But don’t know what happen to it during redirection.

Please guide what is wrong in this code?

Maybe problem occurs in two ways

check your Case sensitive names

or

because of realpath… try with url starting with /

everything just try…i am not sure it will solve your problems

Maybe you could check this:

  1. is it redirect properly?

  2. is there a call for user->getFlashes before the one in your view? (coz for all i know, flash disappear after you display it.)

cmiiw.

Try this in config.php




'user'=>array(

        'allowAutoLogin'=>false,

        'class'=>'CWebUser',

        'autoUpdateFlash' => false, // add this line to disable the flash counter

),

read: http://www.yiiframework.com/doc/api/1.1/CController#redirect-detail

first parameter to redirect() must be URL, second: boolean &#036;terminate=true

so if you want to combine url with params you need:




$this->redirect( $this->createUrl( 'createinventoryitem', array( 'id'=> $id ) ) );



when $trminate !== true code continues to evaluate and renderPartial is called which consumes flashes. You wont see them because content of response having redirect (header Location: XXX) is ignored and discarded. You could however see it in FireBug, which I strongly recommend as HTTP debugger before posting on forum…

I used this method and then user logged out of application. When i tried to login again, it gives me error

"CWebUser.allowAutoLogin must be set true in order to use cookie-based authentication."

I am using yii version "1.1.13 ". This thing did not work for me.

did you tried using ‘allowAutoLogin’=>‘true’

Hi there!

I still have this problem. Using Yii 1.1.14, I have set the option


autoUpdateFlash

to


false

, but still no flash message after a redirect.

Thanks for the help.

Cheers!