CodeIgniter Forums
Can I set a static ID/Password for a page ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Can I set a static ID/Password for a page ? (/showthread.php?tid=71681)



Can I set a static ID/Password for a page ? - cyjuice - 09-12-2018

I have some pages that I want to hide from users, and I just want to do very simple authentication. For example, I just hardcode an ID and a password in my header script, and requires users to enter ID and password to show the contents. Is it possible to do that with CodeIgniter ?


RE: Can I set a static ID/Password for a page ? - Pertti - 09-13-2018

Absolutely. If you are looking for something simple, you can use CodeIgniter session library and check user login state in controller __construct method, if all controller methods should be protected, or in individual methods. If session state isn't available or is not set as successfully logged in, send user to login page, the return once your hard coded passwords was entered.