How to access controller class in CodeIgniter

I wrote an authentication class controller containing a method for checking the user's login status and redirecting it to the login page if he / she is not logged in.

I need to call this function from other controller methods to authenticate the user. What is a good way to do this?

+3
source share
4 answers

Extract this method from this controller.

Assuming you have a User model, this is a great place to host it if it authenticates the user and logs him in.

, , ( ) ().

+2

.

, .

, user_model .

0

, . , , , parent::_check_login(), , , .

0

sumanchalki , , .

CodeIgniter: DRY

This will show you how to create named base controllers, such as an administrator controller, which can contain user authentication logic and more.

0
source

Source: https://habr.com/ru/post/1719729/


All Articles