how to Link php login form to another website

问题: I have a login form in PHP and MySQL for example in a domain named "login.example.com" and I want it to login to another website for example "home.example.com" at the same...

问题:

I have a login form in PHP and MySQL for example in a domain named "login.example.com" and I want it to login to another website for example "home.example.com" at the same time that I login into the first domain, how can I do it without using cookies?

The values that I want to transfer between the domains is the email and the password.

$email       =  e($_POST['email']);                                                            //The email of the user
$password  =  e($_POST['password']);                                                       //The password of the user

回答1:

You have two options,

  1. After login approved, redirect to the second domain (subdomain) and set the session there too
  2. After login approved, load a pixel image with the URL of your second domain (subdomain) EX :

    echo "< img href='https://sub.example.com' />"

In both option, you have to run the script on your second domain (subdomain) to set the session

Update

Example to set a session :

$_SESSION['login'] = $id;

Update 2

It's not a good practice to transfer email and password between domains (subdomains), it's not secure, but you can setting cookie or session to identify the email and password with a unique ID which could be transferred between domains (subdomains)

  • 发表于 2019-03-04 03:13
  • 阅读 ( 191 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除