note 70693 modified in features.http-auth by felipe

From: Date: Sun, 15 Jun 2008 12:10:08 +0000
Subject: note 70693 modified in features.http-auth by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140466@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['CountTrials']++; 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. --was-- (Admins, please remove my last note, I missed changing a German variablename into an English expression). 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['CountTrials']++; 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. http://php.net/manual/en/features.http-auth.php

« previous php.notes (#140466) next »