Can be under thecommon/controller | | Module /controller "Build a class
The class name can be AuthController.class.php or CommonController.class.php(whatever )
namespace common\controller;use think\controller;use think\auth;class authcontroller Extends controller{ public function _initialize () { $auth =new auth (); if ( Controller_name. ' /' . ACTION_NAME == "Index/index") { if (! $auth->check (controller_name. ') /' . action_name, session (' aid ')) { $this->error ("Please login First", u ("Login/login")); } } else { if (! $auth->check ( Controller_name. ' /' &NBSP;.&NBSP;ACTION_NAME,&NBsp;session (' aid ')) { if (Empty ($_session[' aid ')) { echo "<script>"; echo "alert (' Login expired, please log in again! ');"; echo "</script>"; exit (); } echo "<script>"; echo "alert (' You do not have permission to operate! ');"; echo " </script> "; echo "
Classes that require rights management inherit the control class.
class Indexcontroller extends Authcontroller {
This article from the "from the More" blog, reproduced please contact the author!
Tp_auth Management class Usage details