Hi,
I have created a BaseController extending CI Controller :
Code:
<?php namespace App\Controllers;
class BaseController extends \CodeIgniter\Controller
{
protected $env_data;
protected $env_user;
function __construct()
{
$this::init();
}
function init() {
$this->env_data = ['init'=>'yes'];
$this->env_user = [];
if(empty($this->env_user)) {
return redirect()->to('/login');
}
}
}
I then created controller Home2 :
Code:
<?php namespace App\Controllers;
class Home2 extends BaseController
{
public function __construct()
{
parent::init();
}
public function index()
{
print_r($this->env_data);
//return redirect()->to('/login');
return view('welcome_message', $this->env_data);
}
}
Calling Home2 displays array $this->env_data containing "init"=>'yes'. The redirection does not work.
Can someone confirm this is the expected result?
Why is redirection not working in BaseController?
Thanks in advance!