im trying to use codeigniter to create a simple website that involve user restricted areas,
and was wondering how can i design my log in controller so that on every page it load a controller that check if this user is allowed in this page/allow to execute that function.
Question:
i have completed my project but i have 0 experience with this login user access control thing so any advice will be appreciated
You should take a look at the "MY_Controller". Basically, you create a file called MY_Controller.php and place it in application/core (http://ellislab.com/codeigniter/user-guide/general/core_classes.html)
You place a class in this file called MY_Controller that extends CI_Controller
class MY_Controller extends CI_Controller {
public function __construct() {
parent::__construct();
//check if your user is logged in here
}
}
The construct above will be called first before any other controller methods are invoked. So you can check to see if the user is logged in, and if not, redirect to your login form.
There are a lot of different auth libraries that will likely help you with your second question. Check those out and they may help you (don't remember any off the top of my head, but I know you have options).