CodeIgniter Forums
redirect best pratices - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: redirect best pratices (/showthread.php?tid=6644)



redirect best pratices - El Forum - 03-06-2008

[eluser]druid100[/eluser]
hi,

to protect certain functions within my controllers i check within my auth library if the user is logged in. if he is not logged in i redirect him to the login page. however i noticed that after redirect() the program flow continues.

so i seed two choices:

1) write the controller function like this:

function my()
{
if ( !$this->auth->noGuestAccess() )
return;
}

2) write the noGuestAccess() function like

function noGuestAccess()
{

.
.
.

redirect('');
exit();

}

what style would you prefer? exit() is quite harsh ... Big Grin


redirect best pratices - El Forum - 03-06-2008

[eluser]druid100[/eluser]
... ok forget about my post. redirect() discontinues the program flow as i noticed once i started logging correctly. Smile