We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Little Problem with Flash Message

I have a problem to print a message flash when I sign out the sesión. So, this message is not display in my route /view/login/index and I’m using flash direct and flash sesión to know if display it, but neither is displayed.

Hi, You should use Flash Session Message in your controller same: (Doc https://docs.phalcon.io/en/latest/reference/flash.html)

public function LogoutAction()
{
   $this->session->remove('auth');
   $this->flashSession->success('Logout Message');
   return $this->response->redirect('/admin/user/login/');
}

Register flashSession with Di

$di->set('flashSession', function () {
   $flashSession = new \Phalcon\Flash\Session(array(
        'warning' => 'alert alert-warning',
        'notice' => 'alert alert-info',
        'success' => 'alert alert-success',
        'error' => 'alert alert-danger',
    ));
    return $flashSession;
}, true);

Thanks!



17.7k

I'm doing that, but doesn't work... !!!



473

Could you upload file index.volt ?



17.7k

view/index.volt

<!DOCTYPE html>
<html>
    <head>
        {{get_title()}}
    </head>
    <body>
        {{ content() }}
    </body>
</html>