In your controller, you are using it incorrectly, it is not a controller method, so you cannot use $this
to call it.
The helper can be loaded anywhere in your controller functions (or even in your View files, although this is not a good practice) since when you load it before using it. You can load your helpers into your controller constructor so that they become available automatically in any function, or you can load a helper in a specific one that needs it.
To download the assistant you can use
$this->load->helper('name');
Unlike most other systems in CodeIgniter, helpers are not written in an object-oriented format. These are simple, procedural functions. each auxiliary function performs one specific task, independent of other functions.
So, to call a helper function in the controller, you should not use
$this->function_name();
use instead
function_name();
For example, if you have a helper function in a helper file named myCustomHelper.php
as follows
function myHelper() {
then you can load it into the controller and call it as follows
$this->load->helper('myCustomHelper'); myHelper();
but it’s better to load the helpers in the constructor so that it is accessible through the whole script.
Update: If your auxiliary file name is login_helper.php
, you can use it in your controller as follows
$this->load->helper('login_helper'); checkIfLoggedIn($this->session->userdata('loggedIn'));
More details here .