Keeping It DRY |
[eluser]CI-Newb[/eluser]
I was reading over this article: Keeping It DRY . I noticed it was published in 2010, Codeigniter has obviously gone through changes since then. My question: Is this still the most efficient way to accomplish this? Basically my entire app will require the user to be logged in. I would like to make a call "if user is logged in, continue, else redirect" and I would like to avoid having to put this call in every controller / function. Please Advise. Thank you.
[eluser]huynhbathanh[/eluser]
Hello CI-Newb! Maybe yes, I still use the same approach now. You should give a look to many other libraries for authentication here http://blog.pisyek.com/2011/11/5-best-au...deigniter/ for finding the best one for your.
[eluser]Pert[/eluser]
Autoload user model, in <b>__construct</b> method check if user ID is present in session userdata. Same method can do the redirect, just make sure you allow everyone to see the login page I usually follow DRY in the sense of if I know I have to repeat the code multiple times, it will go in it's own function or in a for loop. |
Welcome Guest, Not a member yet? Register Sign In |