note 42198 added to features.http-auth

From: Date: Fri, 07 May 2004 08:15:27 +0000
Subject: note 42198 added to features.http-auth
Groups: php.notes 
Request: Send a blank email to php-notes+get-69306@lists.php.net to get a copy of this message
Quite a good solution for the logout problem: Just tell browser that it is successfully logged in! This works as follows: 1. User clicks logout button 2. Script sends 401 Header 3. User does NOT enter a password 4. If no password is entered, script sends 200 Header So the browser remembers no password as a valid password. Example: <?php if ( (!isset($_SERVER['PHP_AUTH_USER'])) ||( ($_GET["login"]=="login") && !( ($_SERVER['PHP_AUTH_USER']=="validuser") && ($_SERVER['PHP_AUTH_PW']=="validpass") ) ) ||( ($_GET["logout"]=="logout") && !($_SERVER['PHP_AUTH_PW']=="") ) ) { Header("WWW-Authenticate: Basic realm=\"Realm\""); Header("HTTP/1.0 401 Unauthorized"); echo "Not logged out...<br>\n"; echo "<a href=\"index.php?login=login\">Login</a>"; exit; } else if ($_SERVER['PHP_AUTH_PW']=="") { echo "Logged out...<br>\n"; echo "<a href=\"index.php?login=login\">Login</a>"; exit; } ?> ---- Manual Page -- http://www.php.net/manual/en/features.http-auth.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42198 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42198&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42198&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69306) next »