Welcome Guest, Not a member yet? Register   Sign In
Global session check and re-direct
#1
Question 
(This post was last modified: 04-04-2024, 02:00 AM by joho.)

Scenario:

Segmented application, with two or more parts, handling different aspects of access. Similar to how an OAuth situation would look. In the main application, I need to check if there's a valid session. If there is not a valid session, I want to re-direct to the authentication handling application. This could be the "internal" one (still a separate URL, etc) or an "external" one, like Google, Microsoft, whatever.

To avoid having to put a session check in every single Controller function or "route", is it a good idea to put a "global check" in app/Config/Routes.php before anything else, and simply issue a re-direct (and die) before any routes are configured?

Or is there a better/more correct way of doing this the CodeIgniter way?

I guess I should also mention that if the "global session check" fails, the main application should obviously check if we're coming back from an authentication handling app with the correct parameters.

I just realized I could possibly use the Controller's before filter, I think? :-) But then I'd need to add one for every controller, so it's still not a "global session check" per se.

Or is it a $global Filter I should actually use ... ?

-joho
Reply


Messages In This Thread
Global session check and re-direct - by joho - 04-04-2024, 01:49 AM
RE: Global session check and re-direct - by joho - 04-04-2024, 06:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB