Is htaccess-like password protect from PHP possible? -
You know that the htaccess password protection of a folder displays the system's default modal window with a password prompt; I would like to know that I can achieve that functionality, but only after programming, whether it is needed or not.
Which means that the same URL may need password protection in two different situations, so if some of my conditions have not been met, then I like it if I Can easily throw the "box" without the need of own session controller code (or implement) in PHP from PHP (PHP)
The short answer is yes - see example 1, on which I'm down Defense Published:
& lt ?? Php if (! Isset ($ _ SERVER ['PHP_AUTH_USER'])) {header ('WWW-authentication: original realm = "my area"'); Header ('http / 1.0 401 unauthorized'); Repeat 'Text To Read If User Cancel Cancel Button'; Go out; } Else {echo " Hello {$ _SERVER ['PHP_AUTH_USER']}. & Lt; / p & gt;"; Echo "& lt; p & gt; You entered {$ _SERVER ['PHP_AUTH_PW']} as your password. & Lt; / p & gt;"; }? & Gt;
Comments
Post a Comment