Welcome Guest, Not a member yet? Register   Sign In
Password protect entire controller?
#1

[eluser]Unknown[/eluser]
Im wondering where i should put my session check code to password protect and entire controller, right now i have to put it in each function or my app breaks.

Sorry if this has been asked before.
#2

[eluser]eoinmcg[/eluser]
you should put it in your constructor.
e.g.
Code:
// not for CI 1.7 use extends Controller
// for CI2 use extends CI_Controller
class Admin extends Controller {

    function __construct()
    {
        parent::__construct();
        
        $this->_check_password();
        
    }
    
    
    
    function _check_password()
    {
        // do your check here
    }


}

if you wish to check this across multiple controllers you can extend the controller class. you can read more about this here:
http://www.google.com/#sclient=psy&hl=en...5a4a93f9a3




Theme © iAndrew 2016 - Forum software by © MyBB