V
V
Vitaly2017-03-24 13:08:24
Yii
Vitaly, 2017-03-24 13:08:24

Sessions and how to display them?

The problem is that after password recovery (entering a new password), I am redirected to the authorization page, on which it is necessary to display a message that the password has been changed. I'm trying to do it like this:

<?= Yii::$app->session->setFlash('success', 'Password Changed.'); ?>

But the message is not displayed.
I print out the session, everything is there, but stubbornly does not want to be displayed
Added:
According to the documentation, after I call the session should be cleared. That is, the message should not be displayed, I reload the page and there should not be a message, but it is present there $session->getFlash('success');

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2017-03-24
@slo_nik

Good afternoon.
In the controller
In Or view
echo Yii::$app->session->getFlash('success');

M
Maxim Timofeev, 2017-03-24
@webinar

slo_nik and Maxim Fedorov wrote everything correctly, I’ll add that, for example, I use alertifyjs.com instead of the standard one for output<?= Alert::widget(); ?>

M
Maxim Fedorov, 2017-03-24
@qonand

But the message is not displayed.
I print out the session, everything is there, but stubbornly does not want to be displayed

why and where should it go? It is up to you to output it, Yii itself will not output anything. Read here how to work with Flash messages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question