Welcome Guest, Not a member yet? Register   Sign In
my_controller, helper, library or hook?
#1

[eluser]donald.tbd[/eluser]
Hello, i have made a simple log in feature with code igniter. Now i need to protect the controllers that only logged in users should see.
In a video tutorial i viewed it was done like this:
1) In the end of a controller there was a function is_logged() where session was checked and if user wasnt logged in he was redirected.
2) In the beginning of the controller there was a __contructor() function witch launched the is_logged() function.

Now the problem i see here is that i have to make the is_logged() function into every controller that needs protection and that dosent seem very smart. So i would like to know what is the most appropriate way to store the function somewhere where it would be always accessable in my controllers so i wouldt have to rewrite it every time. At the moment i placed it into my_controller but is that the best choice? Maybe it would suite better into a helper or a library or something like that?
#2

[eluser]InsiteFX[/eluser]
MY_Controller

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB