Welcome Guest, Not a member yet? Register   Sign In
Redirect from outside a controller
#2

(05-12-2020, 06:28 AM)imabot Wrote: Is it possible to redirect from outside a controller (from a library to a given URL for example ?).

I read this question : https://forum.codeigniter.com/thread-745...#pid368427 but that does not solve my problem since I don't want to check for authentification.

I update this question since I don't have a satisfying answer :

A simple example: some pages are restricted to some users, depending on the user rights. I need to load the page data before checking if the current user is allowed to visit the page. Filters are not great because I have to load and process the page data twice (once in the filter and once in the controller). Redirecting from models / libraries / helpers is no longer possible. So it must be done in controllers. The problem is that my controllers becomes more and more complicated. Even worse, I can't split my code into functions, because redirection in CI4 is based on return, so I can't redirect from a private method in my controller or BaseController. Any idea?
Reply


Messages In This Thread
Redirect from outside a controller - by imabot - 05-12-2020, 06:28 AM
RE: Redirect from outside a controller - by imabot - 05-14-2020, 11:24 PM
RE: Redirect from outside a controller - by kick - 05-15-2020, 11:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB