In creating a log in process in CodeIgniter I have this for the __construct.
public function __construct() {
parent::__construct();
$this->load->library('session');
$this->load->helper('form');
$this->load->helper('url');
$this->load->helper('html');
$this->load->database();
$this->load->library('form_validation');
$this->load->model('login_model');
}
The index method contains all the necessary code to handle the login.
I am going to set up the log out process and decided instead of creating another controller for the log out I would create a method in the login controller that handles the log out and call it directly.
Obviously the __construct will run when calling the log out method but should I place an if statement in the __construct for items that will not be needed for the log out? For instance not loading the login_model.
This question is not specific to this instance but for overall performance in all the other controllers that I may create and reuse to consolidate code. I am not thinking only about speed but system resources with heavy volume.