Flash message fails after redirect


I have this in my base controller to set user session timeout:

if (Yii::$app->session['userSessionTimeout'] < time()) {



    return $this->goHome();


And on my home page I have this:

<?php if (Yii::$app->session->hasFlash('sessionTimeout')): ?>

    <div class="alert alert-warning text-center">

       <?= Yii::t('app', 'You have been logged-out due to prolonged inactivity.'); ?>


<?php endif; ?>

But for whatever reason, if the the user is actually on the home page while timeout occurres, the flash message on the home page is not visible after redirect.

Any idea why this does not work as expected? I am confused :frowning:

Thanks ahead!

Funny enough - the flash message is working as expected if the code is:


rather than

return $this->goHome();

This is really surprising!