在 2 个网站上登录相同 [英] Same login on 2 websites

查看:38
本文介绍了在 2 个网站上登录相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 web 服务器,里面有主要的 php 应用程序,还有一个文件夹,里面有另一个不同的 web 应用程序.它们是单独开发的,因此每个都连接到不同的数据库并具有不同的登录表单.

I have a web server with the main php application in it and a folder with another different web app in it. They were developed separately, so each one connects to a different database and has different login forms.

我的问题是:如果我在文件夹上的网络应用程序上,我如何连接到第一个网络应用程序的数据库来登录,然后连接回文件夹网络应用程序"数据库以检索其余的信息?

My question is: if i am on the web app on the folder, how can I connect to the database of the first web app just to login and then connect back to the "folder web app" database to retrieve the rest of the information?

对不起,如果我没有很好地表达自己.我不是在寻找为我完成的 php 脚本,我只需要一些关于如何做到这一点的信息

Sorry If I did not express my self well. I am not looking for a php script done for me, i just need some info on how i can do it

谢谢!

推荐答案

您正在寻找使用 PHP 的单点登录脚本.这就是您需要搜索的术语.一个简单的模型是:

You are looking for a Single Sign-On Script using PHP. That's the term you need to search for. A simple model would be:

站点: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/");

查看问题的答案如何进行单点登录使用 PHP?了解更多信息.

See the answers for the question How to do single sign-on with PHP? for more info.

这篇关于在 2 个网站上登录相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆