httpauth04.php to HTML

index

USE AT OWN RISK

Generated: Tue Jul 31 15:22:01 2007 from httpauth04.php 2006/03/06 916 bytes.

<?php
// forth try httpauth04.php

// set USER and PASSWORD
$user = 'user';
$pass = 'pass';

if (!isset ($_SESSION['firstauthenticate'])) {
 session_start();
}
 function authenticate() {
 header('WWW-Authenticate: Basic realm="Sistema autentificaci??noAutoSur"');
 header('HTTP/1_0 401 Unauthorized');
// header("Status: 401 Access Denied"); 
 echo "Unauthorized\n";
 exit;
 }
 if (!isset($_SERVER['PHP_AUTH_USER']) || strcmp ($_SERVER['PHP_AUTH_USER'],$user)!=0 || 
 !isset ($_SERVER['PHP_AUTH_PW']) || strcmp($_SERVER['PHP_AUTH_PW'],$pass)!=0 ||
   !isset ($_SESSION['firstauthenticate']) || !$_SESSION['firstauthenticate']) {
   $_SESSION['firstauthenticate']=true;
   authenticate();
 } else {
   //I destroy the session var now
 session_unset();
 //Your code below
 echo "<p>Welcome ".$_SERVER['PHP_AUTH_USER'].". You are now logged in ...</p>";
 }
?>
 

index

Valid HTML 4.01 Transitional