[eluser]flosaurus[/eluser]
[quote author="Michael Wales" date="1200265545"]
get_user() is a bit different than what we've seen in the past. I usually extend my Controller class, having all of my classes assign the return value to a variable I can us within my view (for echoing out user info, as needed). For any controllers needing Authorization - I make a valid get_user() return value a requirement.
application/libraries/MY_Controller.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Public_Controller extends CI_Controller {
function Public_Controller() {
parent::Controller();
$this->data->user = get_user($this->session->userdata('user_id'));
}
}
class Admin_Controller extends Public_Controller {
function Admin_Controller() {
parent::Controller();
if ($this->data->user === FALSE) {
redirect('user/login');
return;
}
}
}
[/quote]
I'm quite new to CI and would like to know how to use your librarie MY_Controller.php to secure a controler. Could you provide some example ?
thanks a lot