Google Chrome浏览器未保存我的密码

时间:2018-08-21 10:36:30

标签: php passwords

Chrome不会保存用户名/密码(admin / admin)...,但是Firefox会保存。 我的代码中缺少什么吗? 预先谢谢你。

<?php
ob_start();
$valid_passwords = array('admin' => 'admin');
$valid_users = array_keys($valid_passwords); 
$user = $pass = null;

if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']))
{
    $user = $_SERVER['PHP_AUTH_USER'];
    $pass = $_SERVER['PHP_AUTH_PW'];
}

$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);

if (!$validated)
{
    header('WWW-Authenticate: Basic realm="Private access"');
    header('HTTP/1.0 401 Unauthorized');
    exit('Not authorized');
    echo ob_get_clean();
}

0 个答案:

没有答案