• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redirect confusion

#1
HI there.

I am somewhat confused as to how to move from one controller to another. It would appear that the only way to do it is to use a redirect call like this - this is inside a controller....

Code:
class Welcome extends CI_Controller {

function __construct()
{

parent::__construct();

$this->load->library('ion_auth');
}

public function index()
{

if (!$this->ion_auth->logged_in())
{
redirect('auth/login', 'refresh');
}

$this->load->view('welcome_message');
}

Is this correct? As I understand it, this switches program flow from the Welcome Controller to the login method on the Auth controller. And inside the Auth controller, I could do something like :

Code:
if (!$this->ion_auth->logged_in())
{
// redirect them to the login page
redirect('auth/login', 'refresh');
}
else
{
redirect('welcome/index', 'refresh');
}

JMB
Reply


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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.