"calling a controller function in another controller in codeigniter" Answer’s

0

Why not extend the controllers so the login method is within a MY controller (within the core folder of your application) and all your other controllers extend this. For example you could have:

class MY_Controller extends CI_Controller {
    public function is_logged()
    {
        //Your code here
    }
}

and your main controllers could then extend this as follows:

class Home_Controller extends MY_Controller {
    public function show_home()
    {
         if (!$this->is_logged()) {
           return false;
         }
    }
}

For further information visit: Creating Core System Classes

New link is here: https://www.codeigniter.com/user_guide/general/core_classes.html?highlight=core%20classes

Wednesday, March 31, 2021
 
SubniC
answered 10 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share