![]() |
Keeping It DRY - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Keeping It DRY (/showthread.php?tid=58279) |
Keeping It DRY - El Forum - 05-29-2013 [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. Keeping It DRY - El Forum - 05-30-2013 [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-authentication-libraries-for-codeigniter/ for finding the best one for your. Keeping It DRY - El Forum - 05-30-2013 [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. |