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.