gpt4 book ai didi

php - 将 URL 中的用户名和密码传递给 PHP 页面?

转载 作者:可可西里 更新时间:2023-11-01 00:25:21 25 4
gpt4 key购买 nike

我已经在我的本地网络上部署了一个简单的基于 PHP 的应用程序 ( http://www.bigprof.com/appgini/ )。我想要一种实现用户自动登录的方法。安全不是问题。是否可以修改登录页面以接受类似 http://user:pass@app.server.lan/ 的内容? ?

This is the source of the login page ,如果有帮助的话。

如有任何帮助,我们将不胜感激。

最佳答案

HTTP Basic Auth 凭据在 $_SERVER superglobal in the keys PHP_AUTH_USER and PHP_AUTH_PW. 中的 PHP 中可用。

来自 http://php.net/manual/en/features.http-auth.php

if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}

有关进行身份验证的更复杂方法,请查看

关于php - 将 URL 中的用户名和密码传递给 PHP 页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8220520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com