Page 1 of 1

redirecting based on login credentials

Posted: Thu Aug 10, 2006 5:07 pm
by Luke
Is there any possible pitfals when doing this:

Code: Select all

if(!$user->logged_in()){
    // Redirect to login page
    exit;
}
// Do logged in stuff
instead of this:

Code: Select all

if($user->logged_in()){
    // Do logged in stuff
}
else{
    // Redirect to login page
}

Posted: Thu Aug 10, 2006 5:16 pm
by feyd
written correctly (i.e. make sure there's an exit()).. either works just fine.

Posted: Thu Aug 10, 2006 5:34 pm
by Luke
like that?

Posted: Thu Aug 10, 2006 5:43 pm
by feyd
Image

Posted: Thu Aug 10, 2006 10:56 pm
by Ambush Commander
If it's properly encapsulated, you should be able to get away with a return rather than an exit. But yeah, it shouldn't be a big deal (unless you have some majorly important post-script hook)

Posted: Fri Aug 11, 2006 2:32 pm
by Ollie Saunders
First one if preferible because there less logic nesting.