Welcome Guest, Not a member yet? Register   Sign In
Help: Where to put my controller function logged_in()
#1

[eluser]Wondering Coder[/eluser]
I have this function in almost all of my controllers, this prohibit any unauthorized user to access a certain page in my site.
Code:
function is_logged_in()
    {
        $is_logged_in = $this->session->userdata('is_logged_in');
        if(!isset($is_logged_in) || $is_logged_in != true)
        {
            echo 'You don\'t have permission to access this page. <a href="../login">Login</a>';    
            die();        
            //$this->load->view('login_form');
        }        
    }

But what I would like to do is just call this function logged_in in just one controller and not doing a copy-paste thing. Is this the part where I would need to extend my controller? Haven't really tried it though. BTW - It's just been 3 months since I learned using CI.


Messages In This Thread
Help: Where to put my controller function logged_in() - by El Forum - 03-19-2011, 04:31 AM
Help: Where to put my controller function logged_in() - by El Forum - 03-19-2011, 04:49 AM
Help: Where to put my controller function logged_in() - by El Forum - 03-19-2011, 05:08 AM
Help: Where to put my controller function logged_in() - by El Forum - 03-19-2011, 05:27 AM
Help: Where to put my controller function logged_in() - by El Forum - 03-19-2011, 05:48 AM
Help: Where to put my controller function logged_in() - by El Forum - 03-19-2011, 08:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB