Same login on 2 websites

2019-08-08 04:49发布

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!

标签: php mysql web saas
1条回答
【Aperson】
2楼-- · 2019-08-08 05:25

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.

查看更多
登录 后发表回答