Response redirect not working on 2.0.5

Don't know why but on 2.0.5 my redirects are not working at all. (It works well until now)

  // on a controller
    public function logoutAction()
    {
        $this->auth->logout();
        $this->session->destroy();
        $this->flash->success("User disconnects.");
        $this->response->redirect('/');
        die("Why is this happening");
    }

it reachs the die :(

FYI Redirect does not change the execution flow, you need:

public function logoutAction()
    {
        $this->auth->logout();
        $this->session->destroy();
        $this->flash->success("User disconnects.");
        return $this->response->redirect('/');
        die("Why is this happening");
    }


4.4k

To add to what @andresgutierrez said, you should also always send your response when doing a redirect:

$this->response->redirect('/')->send();

I thought the redirect already redirectsas the name says. Actually, the this->response->redirect('/');was working on my logout until 2.0.3 I will change it as you said. Thanks.



2.5k

The return in the example authored by @andresguiterrez would not execute the die would it?



4.4k

The return in the example authored by @andresguiterrez would not execute the die would it?

It shouldn't because you are returning the result of the function on the previous line.