falshes doesnt work after redirect

in Yii2 advanced template after redirecting flashes doesnt work

Here is the code


    

    public function actionTest()

    {

        Yii::$app->getSession()->setFlash('qwe', 'qwe');

        return $this->redirect(['site/test2']);

    }

    public function actionTest2()

    {

        echo Yii::$app->getSession()->getFlash('qwe').'--++';

    }



in not advanced template it works. But in advanced template doesnt work.

According to your code, flash has been set at the top of the body. That’s why you can’t see the flash message. You should print your flash message in view template file as below:


<?= Yii::$app->getSession()->getFlash('qwe') . '--++'; ?>

Let me know if you face any query/concern regarding this.

Thanks,

Saurabh