namespace app\admins\controller;
use think\Controller;
use Util\data\Sysdb;
/**
*
*/
class BaseAdmin extends Controller
{//Account’s session data uses admin as the basis to determine whether the user is logged in. If there is no admin, no user will come in
public function __construct(){
parent::__construct();
//Assign sesson data to admin
$this->_admin = session ('admin');
if (!$this->_admin) {
// //If session has no value, it is judged that the user is not logged in and jumps to the login page
header('Location: /admins.php/admins/Account/login');
exit;
}
}
}
Change the browser and visit http://www.php.demo/admins.php/admins/Home/index
Solve it
Add dump($this->_admin) in front of if and take a look
Or delete the above and replace if directly
if (!session('?admin'))
How to use is_set when judging in if