Why can I access it directly even if I set the judgment?
phpcn_u211985
phpcn_u211985 2018-07-18 14:55:05
0
8
1499

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;

}

}

}


phpcn_u211985
phpcn_u211985

reply all (5)
何人不识君

Change the browser and visit http://www.php.demo/admins.php/admins/Home/index

    ㅤ

    Solve it

      You bad bad

      Add dump($this->_admin) in front of if and take a look

      • reply After refreshing, it jumps back to the login page, but even if the login is successful, it cannot jump to it.
        phpcn_u211985 author 2018-07-18 20:35:00
      anchu

      Or delete the above and replace if directly

      if (!session('?admin'))

      • reply Refresh and jump back to the login page, but the login page cannot be redirected even if the login is successful.
        phpcn_u211985 author 2018-07-18 17:04:01
      • reply The greetings here are in English.
        author 2018-08-23 09:38:29
      anchu

      How to use is_set when judging in if

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!