在 2 个网站上使用相同的登录名
Same login on 2 websites
我有一个网络服务器,里面有主要的 php 应用程序,还有一个文件夹,里面有另一个不同的网络应用程序。
它们是单独开发的,因此每个连接到不同的数据库并具有不同的登录表单。
我的问题是:如果我在文件夹上的 Web 应用程序上,我如何连接到第一个 Web 应用程序的数据库只是为了登录,然后连接回 "folder web app" 数据库以检索其他信息?
对不起,如果我没有很好地表达自己。我不是在寻找为我完成的 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 应用程序,还有一个文件夹,里面有另一个不同的网络应用程序。 它们是单独开发的,因此每个连接到不同的数据库并具有不同的登录表单。
我的问题是:如果我在文件夹上的 Web 应用程序上,我如何连接到第一个 Web 应用程序的数据库只是为了登录,然后连接回 "folder web app" 数据库以检索其他信息?
对不起,如果我没有很好地表达自己。我不是在寻找为我完成的 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? 的答案。