Welcome Guest, Not a member yet? Register   Sign In
Login Box and Logged In User data on each page.
#5

[eluser]Varadha[/eluser]
Hi,

I am a beginner in code igniter. I have my controllers basic setup as follows:

application/core/MY_Controller.php
-----------------------------------
Code:
class MY_Controller extends CI_Controller {
    
    function __construct(){
        parent::__construct();                
    }
    
}

application/controllers/Admin_Controller.php
---------------------------------------------
Code:
class Admin_Controller extends MY_Controller {
    
    function __construct(){
        parent::__construct();
        $this->is_logged_in();
    }
    
    function is_logged_in()
    {        
        $admin_logged_in = $this->session->userdata('admin_logged_in');
        if(!isset($admin_logged_in) || $admin_logged_in != true)
        {
            $data['main_content'] = 'admin_login_view';
            $this->load->view('includes/admin_template', $data);
        }        
    }    
}

application/controllers/admin.php
---------------------------------
Code:
class Admin extends Admin_Controller {
    
    function __construct()
    {
        parent::__construct();        
    }    
    
    function login()
    {
        $data['main_content'] = 'admin_login_view';
        $this->load->view('includes/admin_template', $data);
    }
    
    function members_area()
    {
        $data['main_content'] = 'admin_welcome_view';
        $this->load->view('includes/admin_template', $data);
    }
}

It works fine with login credentials. If i access the members_area() without login, it just loads the welcome view. I have to include many number of functions after login. Should i verify the login session for each and every function? Is there any other way to solve this? I need help on this. Please guide me :question: .

Regards
Varadha


Messages In This Thread
Login Box and Logged In User data on each page. - by El Forum - 03-19-2011, 01:10 PM
Login Box and Logged In User data on each page. - by El Forum - 03-19-2011, 02:08 PM
Login Box and Logged In User data on each page. - by El Forum - 03-19-2011, 03:43 PM
Login Box and Logged In User data on each page. - by El Forum - 03-20-2011, 11:34 PM
Login Box and Logged In User data on each page. - by El Forum - 03-26-2011, 04:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB