Flash doesn't show after Response->redirect

I am setting the flash and then redirecting and no message is showing up. Here is the code:

$this->flash->success('Your comment is saved');
return $this->redirect('forum/show/'.$forum_post_id);

And the redirect function is:

protected function redirect($uri){
        $response = new \Phalcon\Http\Response();
        return $response->redirect($uri);
}

Am I doing something wrong?

Did you register session in your application?

    $di->set('session', function(){
        $session = new Phalcon\Session\Adapter\Files();
        $session->start();
        return $session;
    });


6.0k

Sorry that I didn't mention it - I am using a modified INVO app and the code for registering the session is exactly as yours. By the way if I use $this->dispatcher->forward the message is showing.



86.9k

Are you using Phalcon\Flash\Session instead of Phalcon\Flash\Direct?



6.0k

I am using Phalcon\Flash\Direct:

$di->set('flash', function(){
        return new Phalcon\Flash\Direct(array(
            'error' => 'alert alert-error',
            'success' => 'alert alert-success',
            'notice' => 'alert alert-info',
        ));
    });

If I start using Phalcon\Flash\Session this should solve my problem - thanks!