Codeigniter Is Logged In Check In All Controller.

When you have user management module in your project, you have to check the login status in every page to prevent the unauthorized access. To achieve it, writing the same piece of code in every Page or Controller is bad practice. In codeigniter creating a custom Auth Controller extending the CI_Controller will make it more cleaner code and
later you can extend the Auth check functionality by updating only the extended custom controller. Here is the complete steps.

1. Create MY_Controller.php in your_project_folder/application/core/
2. Check your login session status in the constructor.

3. Then extend all other Controllers using MY_Controller… That’s it.




One thought on “Codeigniter Is Logged In Check In All Controller.

  1. If we are clicking the back button of browser, it is going to the page with errors. It should be redirected to the login page.

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × 5 =