Welcome Guest, Not a member yet? Register   Sign In
returning redirect from parent's function.
#1

Hi, I want to make simple authentication checking method in BaseController.php so it can be accessed by another controller like this:
PHP Code:
protected function mustLoggedIn()
{
    if (
is_null($this->session->get('logged_in'))) {
        
$this->session->setFlashdata(['error' => 'Maaf, anda harus login dulu']);
        return 
redirect()->to('/login');
        exit();
    }

then accessed like this:
PHP Code:
public function beranda()
{
    
$this->mustLoggedIn();
    return 
view('siswa/beranda');

but it didn't work in CI4. Is my method wrong?
How to implement login check like that in CI4?
Reply


Messages In This Thread
returning redirect from parent's function. - by s4if - 05-01-2020, 07:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB