I worked on a web tool that was great and working. I decided to change domain name, so I downloaded everything and uploaded everything on the new domain name.
My login system was really poor, but it worked as follows:
- on domain.com/login.php you provide email/password and on the same page the system checks if they exist in the database.
- If they do, all the information of the user are stored in $_SESSION
- After that you have a redirect to client.domain.com
- Here, if $_SESSION['username'] is set, you are ok. If not, you are redirected back to the login page
To keep the data between the subdomains, I placed this before assigning $_SESSION values:
ini_set("session.cookie_domain", "client.domain.com");
ini_set("session.cookie_domain", "mods.domain.com");
ini_set("session.cookie_domain", "domain.com");
ini_set("session.cookie_domain", "domain.com");
session_start();
$_SESSION['username'] = Other-code;
Of course, as I changed domain name, I changed "domain.com" with the new domain name.
Sadly, I noticed that it stopped working without any reason.. I already checked all the similar questions here, but even if I follow them and I do the things as I should.. $_SESSION is empty for the subdomain.
If you need any other info, let me know. Thanks in advance!
`"* - Are you sure that there isn't relevance with the db code you're using? the servers' php versions, the api used... etc. this could be anything. If you say it used to work, then something went South somewhere.
– Funk Forty Niner Jan 21 '18 at 21:50