Welcome Guest, Not a member yet? Register   Sign In
Redirect confusion
#4

If it's login related, redirecting user to specific login related URL is not that bad, is it?

You can save some time and effort by doing user auth in construct method:
PHP Code:
function __construct()
{
    
parent::__construct();
    
$this->load->library('ion_auth');
    if (!
$this->ion_auth->logged_in()) {
        
redirect('auth/login''refresh');
    }
}

public function 
index()
{
    echo 
'Only registered users will see this';


You could also add a little referrer redirect, so you save current URL before redirecting to login page controller, and on successful login you redirect visitor to that saved URL, instead of default welcome page URL.
Reply


Messages In This Thread
Redirect confusion - by MightBeABitLate - 08-09-2018, 04:06 PM
RE: Redirect confusion - by php_rocs - 08-09-2018, 07:38 PM
RE: Redirect confusion - by MightBeABitLate - 08-09-2018, 10:53 PM
RE: Redirect confusion - by Pertti - 08-10-2018, 01:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB