Home >Backend Development >PHP Tutorial >How to use base HTTP authentication in php, phpbase_PHP tutorial

How to use base HTTP authentication in php, phpbase_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:56:35896browse

How to use base HTTP authentication in php, phpbase

The example in this article describes the method of using base HTTP authentication in php. Share it with everyone for your reference. The details are as follows:

function http_auth($un, $pw, $realm = "Secured Area")
{
 if(!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_USER'] == $un && $_SERVER['PHP_AUTH_PW'] == $pw))
 {
  header('WWW-Authenticate: Basic realm="$realm"');
  header('Status: 401 Unauthorized');
  exit(); 
 }
}

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/987247.htmlTechArticleHow to use base HTTP authentication in php, phpbase This article describes the method of using base HTTP authentication in php. Share it with everyone for your reference. The details are as follows: function http_auth($un,...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn