note 53962 added to features.http-auth
| From: | snagnever at gmail dot com | Date: | Sat, 18 Jun 2005 22:39:58 +0000 |
| Subject: | note 53962 added to features.http-auth | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90636@lists.php.net to get a copy of this message | ||
It forces a auth each time the page is accessed:
(maybe can save someone)
<?
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
header("Pragma: no-cache");
session_cache_limiter("public, no-store");
session_start();
function http_auth()
{
$_SESSION['AUTH'] = 1;
header('HTTP/1.0 401 Unauthorized');
header('WWW-Authenticate: Basic realm="sn4g auth system"');
// The actions to be done when the user clicks on 'cancel'
exit();
}
if( !isset($_SERVER['PHP_AUTH_USER']) or @$_SESSION['AUTH'] != 1 )
{
http_auth();
exit();
}
// Actions do be done when the user has logged
// rest, must clean the session array
$_SESSION = array();
session_destroy();
?>
----
Manual Page -- http://www.php.net/manual/en/features.http-auth.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53962
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53962&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53962&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53962&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53962&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+53962&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53962&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53962&report=yes
Search -- http://master.php.net/manage/user-notes.php