1

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
Adel Store
  • 27
  • 1
  • 1
  • 8
  • The question i linked didnt have a lot of information but this has already been answered here. I cant edit my mark as duplicate but: https://stackoverflow.com/questions/7497864/does-php-set-by-default-the-session-cookie-for-all-subdomains – castis Feb 28 '19 at 20:38
  • with out knowing how the login system works, its impossible to answer. –  Feb 28 '19 at 20:39

1 Answers1

0

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)

Soren
  • 260
  • 4
  • 13
  • This provides an unnecessary way of doing this. The setcookie() function can handle setting a cookie that is available to all subdomains. – castis Feb 28 '19 at 20:39
  • Read the question :S it said Without using cookie ! @castis – Soren Feb 28 '19 at 20:40