Remember the username and password in Web login (complete automatic login)-PHP source code

Source: Internet
Author: User
Remember the user name on the webpage, which is frequently used. There is a check box below for Logon. You can set that users do not need to log on within 7 days or 1 month, if there is a difference between the user name and password in the cookie query on the website system, extract the information and then query it in the database, if the user name and password in the cookie are the same, the user can log on automatically. Remember the user name on the webpage, which is frequently used. There is a check box below for Logon. You can set that users do not need to log on within 7 days or 1 month, if there is a difference between the user name and password in the cookie query on the website system, extract the information and then query it in the database, if the user name and password in the cookie are the same, the user can log on automatically.

Script ec (2); script

Error_reporting (0 );
Session_start ();
?>

The Code is as follows:





The user name and password can be remembered during webpage Logon (automatic logon is completed)


$ Uid = $ _ cookie ['uid'];
$ Pwd = $ _ cookie ['uid'];
If ($ uid! = ''& $ Pwd! = '')
{
// SQL database query Verification
$ _ Session ['uid'] = 'abc ';
}
If ($ _ session ['uid'])
{
Echo 'Member center, post an article, go to http://www.111cn.net to play ';
}
Else
{
?>

The Code is as follows:

}
?>


The Code is as follows:
If ($ _ post)
{
$ Info = $ _ post;
If ($ info ['uid']! = ''& $ Info ['pwd']! = '')
{
// SQL query operation. Verify the user name and password in the database.

If (intval ($ info ['checkbox'])
{
Setcookie ('uid', $ info ['uid'], time () + 3600*24*7, '/', '192. 168.0.118 ');
Setcookie ('pwd', $ info ['pwd'], time () + 3600*24*7, '/', '192. 168.0.118 ');
}
$ _ Session ['uid'] = $ info ['uid'];
}
}

// Original article on this site is reprinted with the original article from http://www.111cn.net/php tutorial er/php.html

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.