The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

[v2] Is $app->redirect() a good way to refuse access to a page

Luca's Avatar


16 Oct, 2015 12:45 PM

Currently I'm using middleware to check whether someone is allowed to access certain routes of my application. I'm feeling unsure about using $app->redirect() within the middleware to redirect the user to my error page.

Should I add $app->stop(); after the redirect to make sure that the user really can't enter the page. And which HTTP-status code should I use for access-denied-redirects?

Regards! :)

  1. Support Staff 1 Posted by Andrew Smith on 16 Oct, 2015 12:55 PM

    Andrew Smith's Avatar

    You won't need to call $app->stop() manually because $app->redirect() calls $app->halt() which in turn calls $app->stop().

  2. 2 Posted by Luca on 16 Oct, 2015 02:31 PM

    Luca's Avatar

    Thank you very much! :)

  3. Luca closed this discussion on 17 Oct, 2015 11:59 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac