Welcome Guest, Not a member yet? Register   Sign In
How do I handle views loaded based on conditions correctly?
#3

[eluser]Unknown[/eluser]
[quote author="bhumes" date="1307755807"]Redirecting is the way to go.

Code:
$this->load->helper('url');
redirect('bills');
[/quote]

Good to know

Would it be a bad idea to extend the CI controller to include an authorization method that redirects to /auth/ if not logged in? This way I don't have to do

Code:
if (!is_authorized()) {
  redirect();
}

in every controller?

Also, thanks for the reply.

Edit: I just implemented something like that, doing:

Code:
class MY_Controller extends CI_Controller {
    public function __construct() {
        parent::__construct();
        // Add authorization check
        if (!is_authorized()) {
            redirect('auth');
        }
    }
}

seems to work nicely.


Messages In This Thread
How do I handle views loaded based on conditions correctly? - by El Forum - 06-10-2011, 02:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB