我有一个 web 服务器,其中包含主要的 php 应用程序,还有一个文件夹,其中包含另一个不同的 web 应用程序。 它们是单独开发的,因此每个都连接到不同的数据库并具有不同的登录表单。
我的问题是:如果我在文件夹上的网络应用程序上,我如何连接到第一个网络应用程序的数据库只是为了登录,然后连接回“文件夹网络应用程序”数据库以检索其余的信息?
对不起,如果我没有很好地表达自己。我不是在寻找为我完成的 PHP 脚本,我只需要一些关于如何做的信息
谢谢!
最佳答案
您正在寻找使用 PHP 的单点登录脚本。这就是您需要搜索的术语。一个简单的模型是:
站点:http://auth.local/
:
<?php
// Get the request.
// Validate the session.
// Pass a Secure Hash and log the user in to the main domain.
?>
站点:http://site1.local/
:
<?php
// Check if there is a session.
// If already logged in, no problem.
// If not, send him back to auth.
header("Location: http://auth.local/?redirect_to=http://site1.local/");
站点:http://site2.local/
:
<?php
// Check if a session is there.
// If already logged in, no problem.
// If not, send him back to auth.
header("Location: http://auth.local/?redirect_to=http://site2.local/");
查看问题的答案 How to do single sign-on with PHP?了解更多信息。
关于php - 在 2 个网站上使用相同的登录名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33324169/