This article is mainly for everyone to introduce the thinkphp implementation login Exit function, with a certain reference value, interested in small partners can refer to
The example of this article for everyone to share the thinkphp implementation of login Exit function of the specific code for your reference, the specific content as follows
<?php/** * User Login and Exit * After successful registration, the page will be redirected to the login login page * When the data is submitted to the landing page, the verification code must be executed before the login operation */public function Checkyzm ($yzm) {$verif Y=new \think\verify ();//Instantiate the Verify method with TP if ($verify->check ($YZM)) {//Call the Check method return true;} else{echo ' Verification code error '; Exit (); }}public function Login () {if (!is_post) {$this->display ();} else{//If verification code is verified via if ($this->checkyzm (' Post.yzm ')) {$username =i (' post.username '); $user =d (' user ')->where ("Username= ' $username '")->find (); Post the password splicing salt MD5 after the password = database password, then through if (MD5 (I (' Post.password '). $user [' salt ']) = = = $user [' Password ']{cookies (' username ', $userp [' username ']);//write Cookie $this->redirect ('/');//Jump to Home}else{echo ' username or password is incorrect '; }}}}/**V Layer * Exit Login * Read cookie $Think. cookie *///without cookie data Hello Welcome to <if condition= "$Think. Cookie.username eq Null" >< A href= "{: U (' Home/user/login ')}" rel= "external nofollow" rel= "external nofollow" style= "color: #50884b" > Login </a > |<a href= "{: U (' Home/user/reg ')}" rel= "ExternaL nofollow "style=" color: #50884b "> Free registration </a> |<else/>{$Think. Cookie.username}|<<a href=" {: U (' Home/user/login ')} "rel=" external nofollow "rel=" external nofollow "style=" color: #50884b "> Exit </a> </if >/** * Exit method * 1,cookie set to NULL, delete cookie * 2. Jump to Homepage */Public Function logout () {cookie (' username ', null); $this->redirect ('/'); };
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!