Elementary introduction of PHP User identity authentication (a) _php

Source: Internet
Author: User
Keywords User authentication identity HTTP make password
Tags http authentication
Elementary introduction of PHP User identity authentication (a)
Popcorn September 25, 2001 Www.westxj.net
When you browse the site, you will often encounter certain pages that require user and password verification.
This requires that we write the appropriate authentication program to implement this functionality. Here are some of my learning process and experience, I hope to be helpful to everyone.
(i), HTTP authentication-based single-user authentication:
We use the function header () to send HTTP headers to force validation, the client browser pops up to enter a user name and Password dialog box, the client's user input information, is transmitted to the server after the $php_auth_user, $PHP _auth_ PW in these two global variables. With these variables, user and password validation can be performed.
The following program can be used for simple authentication
if ($PHP _auth_user!= ' Jane ' | | $PHP _auth_pw!= ' 123456 ')
{
Header ("Www-authenticate:basic realm=\" popcorn landing \ ");
Header ("http/1.0 401 Unauthorized");
echo "Authentication Error! ";
Exit
}
?>
(Note: When using HTTP authentication, it must be run as an Apache module, and if you are using CGI mode PHP, you cannot implement HTTP-based authentication.) )
----to be continued-----
  • 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.