Yii Framework Forum: falshes doesnt work after redirect - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

falshes doesnt work after redirect Rate Topic: -----

#1 User is offline   Nurbek 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 26-August 09

Posted 25 July 2015 - 05:43 AM

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.
0

#2 User is offline   Saurabh Dhariwal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 27-September 13

Posted 29 July 2015 - 06:32 AM

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
Thanks,
Saurabh Dhariwal
Skype ID: dhariwal.saurabh
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users