Guest User

php basic auth

a guest
Feb 17th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.31 KB | None | 0 0
  1. <?php
  2.  
  3. if (!isset($_SERVER["PHP_AUTH_USER"]) || !isset($_SERVER["PHP_AUTH_PW"])) {
  4.     http_response_code(401);
  5.     header("WWW-Authenticate: Basic realm=\"?\"");
  6.     exit();
  7. }
  8.  
  9. if ($_SERVER["PHP_AUTH_USER"] != 'a' || $_SERVER["PHP_AUTH_PW"] != 'a') {
  10.     http_response_code(401);
  11.     exit();
  12. }
  13.  
  14. exit("hey");
Advertisement
Add Comment
Please, Sign In to add comment