Welcome Guest, Not a member yet? Register   Sign In
Redirect Not Working CI4
#3

The only solution I found is move the Session Checker to the method Index of the Dashboard.

PHP Code:
<?php

namespace App
\Controllers;

class Dashboard extends BaseController
{

    public function index()
    {

        if (!(isset($_SESSION['user_logged_in']))) {

            return redirect()->to(base_url('public/login'));
            
        
} else {

            echo view('templates/header');
            echo view('dashboard_view');
            echo view('templates/footer');

        }
        
    
}


It's work in that way... but I will have to add this code to all index method in all my Controllers and I dont want that. I would like to have the Session Checker in the Base Controller so all Controllers will check the Session.

Any way that the redirect() works from BaseController?
Reply


Messages In This Thread
Redirect Not Working CI4 - by Programaciones Web - 11-07-2019, 07:57 AM
RE: Redirect Not Working CI4 - by adelbak - 11-07-2019, 11:52 AM
RE: Redirect Not Working CI4 - by Programaciones Web - 11-08-2019, 01:38 AM
RE: Redirect Not Working CI4 - by dave friend - 11-08-2019, 06:22 AM
RE: Redirect Not Working CI4 - by Chivinsdev - 11-11-2019, 09:21 AM
RE: Redirect Not Working CI4 - by Juan Fajardo - 06-02-2020, 10:49 AM
RE: Redirect Not Working CI4 - by kilishan - 11-11-2019, 09:58 AM
RE: Redirect Not Working CI4 - by InsiteFX - 11-12-2019, 04:07 AM
RE: Redirect Not Working CI4 - by Gary - 04-18-2020, 03:22 PM
RE: Redirect Not Working CI4 - by Gary - 04-18-2020, 07:16 PM
RE: Redirect Not Working CI4 - by Leo - 04-20-2020, 02:42 AM
RE: Redirect Not Working CI4 - by jim1001 - 05-21-2020, 04:26 AM
RE: Redirect Not Working CI4 - by dave friend - 05-21-2020, 01:02 PM
RE: Redirect Not Working CI4 - by Leo - 05-22-2020, 09:46 AM
RE: Redirect Not Working CI4 - by ivanfdr - 04-22-2020, 09:16 PM
RE: Redirect Not Working CI4 - by abeni_ab - 07-22-2020, 09:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB