Does thinkphp verify whether a user is logged on? How did you verify it? Is it verified once in every Action? Or write it in a public function for calling?
Reply to discussion (solution)
Generally, it is called.
However, I am using this method to save the cookie after logging on. The php file or a specific location is used to verify whether the cookie exists.
Generally, it is called.
However, I am using this method to save the cookie after logging on. The php file or a specific location is used to verify whether the cookie exists.
Well, this is acceptable. I am in trouble. In common functions, I add user verification methods to determine whether to call user verification methods by judging the values of a and m. However, I added a verification code to the logon interface. when I called the verification code, the verification code was rejected. Find a more convenient method.
A public class can be written for inheritance.
Generally, I do this:
class BaseAction extends Action{ function _initialize(){ if(!in_array(MODEL_NAME.'_'.ACTION_NAME,explode(',',"Public/login,Public/LoginOn,Public/verify"))){ if(!isset($_SESSION['login]) !! empty(session('login'))) $this->redirect("/login"); } }}
The code may be wrong,
Generally, I do this:
class BaseAction extends Action{ function _initialize(){ if(!in_array(MODEL_NAME.'_'.ACTION_NAME,explode(',',"Public/login,Public/LoginOn,Public/verify"))){ if(!isset($_SESSION['login]) !! empty(session('login'))) $this->redirect("/login"); } }}
The code may be wrong,
Thank you! this is feasible. I just tried it. I didn't expect that the verification code actually called the action under a model. The code has a small error. "_" should be replaced with "/".