Welcome Guest, Not a member yet? Register   Sign In
Autorun php code?
#2

[eluser]jwburnside[/eluser]
I usually build a Base Controller for code that needs to be on each page or is vital to the site operations, and then extend that base controller in all of my other controllers.

For instance, since you have a login requirement, you will need an authentication system. This will go in your base controller since all users must pass the authentication to access you pages. Something along these lines:

Code:
$this->load->library('auth');
$this->id = $this->auth->username();

// Check for Authentication
if(!$this->auth->is_authenticated())
{
    //Redirect back to login
}
else
{
//Set the session or whatever
}
Technically this can go in each function in your main controller, but why repeat code! At any rate, it shouldn't go in your view, since that defeats the purposes of having a nice, ordered MVC structure.


Messages In This Thread
Autorun php code? - by El Forum - 05-04-2011, 09:32 AM
Autorun php code? - by El Forum - 05-04-2011, 10:34 AM
Autorun php code? - by El Forum - 05-04-2011, 10:54 AM
Autorun php code? - by El Forum - 05-04-2011, 11:10 AM
Autorun php code? - by El Forum - 05-04-2011, 01:16 PM
Autorun php code? - by El Forum - 05-04-2011, 01:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB