Inheritance of Controller in Thinkphp3.2.3

When using the user login privilege of the background management module, how other users prevent other users from directly accessing the backbron home page, and you need to verify whether you want to log in to the administrator. Because the background of the background is more than one page, it will be troublesome if you do permission management for each page.

In TP, by implementing a public controller, let the background controller directly inherit this public controller, when accessing the home page, will visit this public controller, as long as In this public controller, do your administrator’s verification.

Public controller class is placed in the Application \\ Common \\ Controller directory, named commonController.class.php, named space is as follows:

When the subclass is inherited: the ADMIN module is used here

namespace Common\Controller;
use Think\Controller;

class CommonController extends Controller {
    public function _initialize(){

Display ();}}

Clear session:
   public function logout () {// Clear session $ _SESSION = array (); session (null); session ('[design "); redirect (' / admin.php / login / login", 2, 'Exit Success, return home'); exit;}  

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment