note 105379 deleted from features.http-auth by cmb
| From: | cmb@php.net | Date: | Sun, 13 Oct 2019 08:19:59 +0000 |
| Subject: | note 105379 deleted from features.http-auth by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212644@lists.php.net to get a copy of this message | ||
Note Submitter: luismontreal at gmail dot com
----
Using sessions like this makes the enter auth values at each request
<?php
if($_SESSION['http_logged'] != 1) {
$_SERVER['PHP_AUTH_USER'] = '';
$_SERVER['PHP_AUTH_PW'] = '';
}
if ($_SERVER['PHP_AUTH_USER'] != $your_username || $_SERVER['PHP_AUTH_PW']
!= $your_password ) {
$_SESSION['http_logged'] = 1;
header('WWW-Authenticate: Basic realm="realm"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else {
$_SESSION['http_logged'] = 0;
}
?>