Welcome Guest, Not a member yet? Register   Sign In
var $route to Auth controller
#1

(This post was last modified: 02-14-2020, 09:12 AM by nicolas33770.)

Hello everyone,

sorry for that silly question but i'm new to CodeIgniter.

I Use CodeIgniter 3 and Ion Auth. I would like to know the best way to share the variable $route['default_controller'] in /application/config/routes.php to /application/controllers/Auth.php in public function login() for redirect('/','refresh').

I did not find information on how to share this type of data in the documentation.

I suppose it is possible to go through the global session variable but it is not very clean I think, and I do not know where to set it (in routes.php)?

CodeIgniter being in MVC should I suppose pass the variable routes via the function __construct () of the controllers Auth.php? But I don't know where to initialize the controller when loading ... can you help me?


Thanks for your help

Ok I find the good way I think. Auth is extends CI_Controller and I can access to $this parameters. with print_r($this), I can find my parameter $this->router->default_controller. And I can directly use it in my auth Controller.

Code:
redirect('/'.$this->router->default_controller, 'refresh');

I have other question. If I need add new global parameters to $this is it possible ? Where I the best to do that ? And how ?
Reply


Messages In This Thread
var $route to Auth controller - by nicolas33770 - 02-14-2020, 08:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB