downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Voting

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

The Note You're Voting On

danja at k0a1a dot net
4 years ago
a simplistic login/logout script, mainly for development of user-customizable pages.

<?php
session_start
();

$autorized = false;

if(isset(
$_GET['logout']) && ($_SESSION['auth'])) {
   
$_SESSION['auth'] = null;
   
session_destroy();
    echo
"logging out...";
}

if(isset(
$_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
   
$user = test;
   
$pass = test;
    if ((
$user == $_SERVER['PHP_AUTH_USER']) && ($pass == ($_SERVER['PHP_AUTH_PW'])) && ($_SESSION['auth'])) {
       
$authorized = true;
    }
}

if (isset(
$_GET["login"]) && (! $authorized)) {
   
header('WWW-Authenticate: Basic Realm="Login please"');
   
header('HTTP/1.0 401 Unauthorized');
   
$_SESSION['auth'] = true;
    print(
'Login now or forever hold your clicks...');
    exit;
}

?>

<h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1>

<?

?>

<< Back to user notes page

 
show source | credits | stats | sitemap | contact | advertising | mirror sites