/ Published in: PHP
Expand |
Embed | Plain Text
function http_auth($un, $pw, $realm = "Secured Area") { { } }
Comments
Subscribe to comments
You need to login to post a comment.
tylerhall on 11/30/-1
27 people have marked this snippet as a favorite
daniel
luman
Roshambo
nex
jkochis
kawikak
mafro
funkyD
bitcrumb
vali29
hudge
willcodeforfood
benrasmusen
damarev
tzangms
JimiJay
jachin
SpinZ
romanos
joaosalless
salibaray
silentbob84
osirisinternet
bobbym245
mecha
tspitzr
ringo380
function http_auth($un, $pw, $realm = "Secured Area") { { } }
Subscribe to comments
You need to login to post a comment.
hi there
I like this function however I would change it to:
<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( 0 ); } }>Or even better function http_auth ($username, $password, $realm = "Secured Area" ) {
More lines of code, but I find it a bit more readable.