note 70685 added to features.http-auth
| From: | SlamJam at osu1 dot php dot net | Date: | Mon, 23 Oct 2006 22:28:48 +0000 |
| Subject: | note 70685 added to features.http-auth | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119048@lists.php.net to get a copy of this message | ||
I used Louis example (03-Jun-2006) and it works well for me (thanks).
However, I added some lines, to make sure, the user does only get the Authentification-Window a few
times:
<?php
$realm = mt_rand( 1, 1000000000)."@YourCompany";
$_SESSION['realm'] = $realm;
// In the beginning, when the realm ist defined:
$_SESSION['CountTrials'] = 1;
?>
And then when it comes to check the authentification (ZEND-Tutorial):
<?php
// Not more than 3 Trials
if (!$auth) {
$_SESSION['AnzVersuche']++;
if ($_SESSION['CountTrials'] == 4) {
session_destroy() ;
header('Location: noentry.php');
exit ;
} else {
header("WWW-Authenticate: Basic realm=".$_SESSION['realm']);
header("HTTP/1.0 401 Unauthorized");
echo 'Authorization Required.';
exit;
}
} else {
echo '<P>You are authorized!</P>';
}
?>
noentry.php is slightely different from comeagain.php.
----
Server IP: 66.163.161.117
Probable Submitter: 84.227.19.240
----
Manual Page -- http://www.php.net/manual/en/features.http-auth.php
Edit -- https://master.php.net/note/edit/70685
Del: integrated -- https://master.php.net/note/delete/70685/integrated
Del: useless -- https://master.php.net/note/delete/70685/useless
Del: bad code -- https://master.php.net/note/delete/70685/bad+code
Del: spam -- https://master.php.net/note/delete/70685/spam
Del: non-english -- https://master.php.net/note/delete/70685/non-english
Del: in docs -- https://master.php.net/note/delete/70685/in+docs
Del: other reasons-- https://master.php.net/note/delete/70685
Reject -- https://master.php.net/note/reject/70685
Search -- https://master.php.net/manage/user-notes.php