Bug with setFlash

Some time Yii::app()->user->setFlash is working some time not. why?

here is my code.


if ($this->validateToLogin($model->email)) {

                    $model->sendRegEmail();

                    $model->save(false);

                    Yii::app()->user->setFlash('success', 'Siz registratsiyadan muaffaqiyatli o\'tdingiz');

                    $this->redirect("/");

                }

This code looks correct, maybe the validation fails sometime?

I know this is an old post, but I wanted to add an answer for those stumbling across it. The problem is you are redirecting after setting the flash. This makes a new request, in effect erasing any values you’ve set.

To get the flash message to appear you must render the page and your view must have code to display the user’s flashes.