Skip to content

Instantly share code, notes, and snippets.

@vermaslal
Created October 28, 2015 05:56
Show Gist options
  • Save vermaslal/aef17f1c59f4c4ee500a to your computer and use it in GitHub Desktop.
Save vermaslal/aef17f1c59f4c4ee500a to your computer and use it in GitHub Desktop.
Prompt Browser password dialog : Browser Password Dialog « Login Authentication « PHP
<?php
if (!isset($_SERVER['PHP_AUTH_USER']) || ($_SERVER['PHP_AUTH_USER'] != 'specialuser') || ($_SERVER['PHP_AUTH_PW'] != 'secretpassword')) {
header('WWW-Authenticate: Basic Realm="Secret Stash"');
header('HTTP/1.0 401 Unauthorized');
print('You must provide the proper credentials!');
exit;
} else {
print('Authenticated!');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment