class MY_Controller extends CI_Controller { public function __construct() { parent::__construct(); if (!$this->session->userdata('user_id')) { redirect('login'); } } } class Dashboard extends MY_Controller { public function index() { // Verify that user is authenticated // Show dashboard } } class Profile extends MY_Controller { public function index() { // Verify that user is authenticated // Show profile page } }
class MY_Controller extends CI_Controller { public function __construct() { parent::__construct(); $this->lang->load('my_strings', 'english'); } } class Dashboard extends MY_Controller { public function index() { // Load localized strings from my_strings/english_lang.php // Show dashboard } } class Profile extends MY_Controller { public function index() { // Load localized strings from my_strings/english_lang.php // Show profile page } }
class MY_Controller extends CI_Controller { protected $api_key; public function __construct() { parent::__construct(); $this->api_key = $this->input->get('api_key'); if ($this->api_key != '123456') { exit('Unauthorized access'); } } } class Users extends MY_Controller { public function get_users() { // Verify that request is authorized using api_key // Return list of users } } class Products extends MY_Controller { public function get_products() { // Verify that request is authorized using api_key // Return list of products } }Package library: CodeIgniter