问题:
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,
- After login approved, redirect to the second domain (subdomain) and set the session there too
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)