Its very easy
1)First create a new file in controller folder e.g Classname.php
2)Edit that file
class Classname Extends CI_Controller
{
}
3) Put your new functions inside this class file
Put the class file into library folder
the file like this
class Authenticate {
public function __construct()
{
$this->ci =& get_instance();
}
public function is_logged_in()
{
$sessionid = $this->ci->session->userdata('moderId');
if($sessionid)
{
return isset($sessionid);
}
else if(!$sessionid) {
redirect(base_url() . 'moderator');
}
}
}
And in the controller file, call that class function like this
class B2bcategory extends CI_Controller {
function __construct() {
parent::__construct();
$this->authenticate->is_logged_in();
}
}