Home  >  Article  >  Backend Development  >  How to prevent users from directly entering method instances in the php background_PHP tutorial

How to prevent users from directly entering method instances in the php background_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:25:59837browse

1) Create a BaseController controller and inherit the Controller (all background operations must inherit the BaseController):

Add in BaseController:

Copy code The code is as follows:

public function checkLogin() {

if (Yii::app ()->authority->isLogin() == Yii::app()->authority->getStatus('NOTLOGIN')) {
                              $url = $this->createUrl('user /login');
                    if (Yii::app()->request->isPostRequest && Yii::app()->request->isAjaxRequest) { code' => -101, 'message' => 'The user is not logged in ', 'callback' => 'window.location="' . $url . '";'));
          } else if (Yii::app()->request->isAjaxRequest) {
          echo '