Same login on 2 websites

戏子无情 提交于 2019-12-11 11:51:45

问题


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?

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

Thanks!


回答1:


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:

Site: http://auth.local/:

<?php
  // Get the request.
  // Validate the session.
  // Pass a Secure Hash and log the user in to the main domain.
?>

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

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

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



来源:https://stackoverflow.com/questions/33324169/same-login-on-2-websites

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!