Do not know why, the session in the constructor is not working but in other method. Help me to find this out. Thanks in advance.
PHP Code:
<?php
namespace App\Controllers;
class Manage extends BaseController
{
protected $session;
public function __construct(){
$this->session = \Config\Services::session();
if( !$this->session->has('isCnProL') ) return redirect()->to(base_url('login')); // Not working
}
public function new_post()
{
if( !$this->session->has('isCnProL') ) return redirect()->to(base_url('login')); // Working
$this->manageView('post-new');
}