[eluser]jcjc[/eluser]
I've created a MY_Controller to house an isLoggedIn function which will check if the session data has been set before allowing them into a page. Problem I have is when I go to view another page that's protected it reloads the dashboardView. I need it check if user is logged in before showing the page else send them to login.
Code:
class MY_Controller extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->is_logged_in();
}
function isLoggedIn()
{
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != TRUE)
{
redirect('/login');
}
else
{
//THIS LINE I THINK NEEDS TO BE DYNAMIC.
$this->load->view('dashboardView');
}
}
[eluser]ivantcholakov[/eluser]
I your site has pages that are publicly accessed and pages accessed by logged users only, I think you need to create yet another base controller, sort of MY_Public_Controller.