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

#1
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!
Reply


Messages In This Thread
Redirect - by oliver - 12-06-2018, 12:57 PM
RE: Redirect - by kilishan - 12-06-2018, 01:56 PM
RE: Redirect - by oliver - 12-09-2018, 03:43 AM
RE: Redirect - by InsiteFX - 12-09-2018, 10:57 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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