PHP 7.2.0 Beta 3 Released

Voting

Please answer this simple SPAM challenge: min(four, two)?
(Example: nine)

The Note You're Voting On

djreficul at yahoo dot com
11 years ago
Well, I think it's easy to make authentification works correctly. I use a session var to force authentication everytime a user visit the logging area.

<?php
if (!isset ($_SESSION['firstauthenticate'])) {
   
session_start();
}
  function
authenticate() {
   
header('WWW-Authenticate: Basic realm="Sistema autentificación UnoAutoSur"');
   
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
}
?>

<< Back to user notes page

To Top