thinkphp How to implement the login Exit function

Source: Internet
Author: User
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" >&lt 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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.