Redirect with http code to slim route


I am creating a validation session and i have a issue when the session is not valid i am redirecting the user to route with name /login with status code 403 but the user arrive the /login it has a 200 but doesn’t have a 403

Can you show the redirect code you are using? You would typically want something like this:

return $response->withRedirect($this->router->pathFor('login'), 403);
1 Like

Also, note that there is a redirect happening here… So the initial response will be a 403 to whatever URL they requested, but then they will be redirected to the new URL, which will likely return a 200 (and should return a 200).

If you want the response to be a 403 and be done with it you can do that, just return the response with a 403 and don’t redirect.

1 Like

Hi, i can solve my problem. Thanks for your help. I am wrapping a request slim because it hasn’t a static methods. I return a 403 status code without redirect and i am showing the content with apache error handler