Welcome Guest, Not a member yet? Register   Sign In
How to implement codeigniter login system ?
#2

[eluser]nelson.wells[/eluser]
There are a few different ways to do it. You can do it the way you're suggesting (though you don't use isset with CI's session class), but there are better ways. I'll tell you the way I do it, I'm sure someone else can offer other solutions.

I built an authorization library that tracked whether or not the user is logged in. I keep track of the data with sessions. In controllers that required the user be logged in, I can do something like this in the constructor.

Code:
if($this->auth->logged_in() && $this->auth->level > 5)
{
    //don't do anything, display the page as per the function
}
else
{
    //redirect to the login page
    redirect("login");
}

If you need more finely grained control, you could do this step in individual functions instead. If you wanted more broad control, you can put this functionality in a MY_ controller, and every controller that needd to be gaurded could inherit it.

Hope that helps.


Messages In This Thread
How to implement codeigniter login system ? - by El Forum - 03-08-2010, 12:04 PM
How to implement codeigniter login system ? - by El Forum - 03-08-2010, 12:28 PM
How to implement codeigniter login system ? - by El Forum - 03-08-2010, 02:30 PM
How to implement codeigniter login system ? - by El Forum - 03-08-2010, 03:49 PM
How to implement codeigniter login system ? - by El Forum - 03-08-2010, 04:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB