codeigniter redirect to different controller codeigniter redirect to different controller codeigniter codeigniter

codeigniter redirect to different controller


First of all, you are doing a very poor job of checking if the user is authenticated (just passing username/pass to model isn't best, should process / check it before sending to model).

You can make redirects easily by including the helper 'URL' and simply use:

redirect('/controller/method');

or in a real world example:

redirect('/main');

Reference Link


There is another way but similar to redirect(), if your controller is Rest controller

restserver

You can use rest client in another controller to call methods on the server controller

restclient


redirect('controller/function');

For example you can have redirect('auth/login'); with routes as

$route['auth/login'] = 'auth/auth/index';