CodeIgniter Forums

Full Version: Can I set a static ID/Password for a page ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ?
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.