The method of using session to implement user login verification in thinkphp _php tutorial

Source: Internet
Author: User

A method of user login verification using session in thinkphp


The user boarded a home page there are two states, one is similar to the identity of the visitor login, the other is the identity of the past has been logged on as a server authenticated login.

For both of these logins, the main words are:

When we use thinkphp, first of all, he does not improve the login verification function, is only in the path to do relatively safe, because if we do not have sufficient authentication login identity, the user can completely try to login to your background management, then this is very scary, so, The first thing to understand is a very important business logic.

If you follow the normal input user name password to log in, before jumping we should write session data, and then log in with the data, but if the user does not enter a password to log in, then it must not have session data, we judge the existence of the session data, But this judgment should be before the jump.

Therefore, the session data deposit and reading is very important, it must be flexible to use the line:

The following is the login instance code, due to security factors, and not all released, for reference only

Class Managercontroller extends Controller {public    function login () {    //////This is the login verification module if (empty ($_post) | | ($_post[' username ']== ' Please enter your username ') {$this->display ();} else{$info =d (' userinfo '); $res = $info->select (); $username =$_post[' username ']; $password =md5 ($_post[' password ') $ver =0;foreach ($res as $key + $value) {if ($res [$key] [' username ']== $username && $res [$key] [' Password ']== $password) {$ver + +;}} if ($ver) {s (' username ', $username); $this->assign (' username ', s (' username ')); $this->display (' Index/index '); /$this->success ("Login Successful", U (' Index/index '));} else{//echo "

Incorrect user name or password

"; $this->assign (" Error_info "," Your user name or password is wrong "); $this->display ();}}


http://www.bkjia.com/PHPjc/1011357.html www.bkjia.com true http://www.bkjia.com/PHPjc/1011357.html techarticle the method of using session to implement user login verification in thinkphp the user boarded a home page there are only two states, one is class in the identity of visitors to log in, the other is once landed ...

  • Related Article

    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.