Yii2 setFlash后redirect后,getFlash总是为空

WBOY
Release: 2016-06-06 20:24:42
Original
1133 people have browsed it

为啥呢?

<code class="php">Yii::$app->session->setFlash('danger', 'City Wide Curfew');
return Yii::$app->controller->redirect(['/default/index'], 307);</code>
Copy after login
Copy after login

在 /default/index 中 echo Yii::$app->session->getFlash('danger') 总是为空?

回复内容:

为啥呢?

<code class="php">Yii::$app->session->setFlash('danger', 'City Wide Curfew');
return Yii::$app->controller->redirect(['/default/index'], 307);</code>
Copy after login
Copy after login

在 /default/index 中 echo Yii::$app->session->getFlash('danger') 总是为空?

我的解决方法是:在Yii::$app->controller->redirect()后,Yii::$app->end()

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template