I got a system, where each client has their own subdomain. The users can log into the system directly from their own subdomain, but I want to add the opportunity to login directly from the domain, and afterwards send them to the subdomain. It is important that the session is only set on the actual subdomain, and not on any other subdomains or the main domain.
All login-processes are made through jQuery/AJAX.
I've tried the following:
- On domain.com a user fills out the login-form, and a call is made to domain.com/ajax/front-login.php
- From this AJAX-file the user is validated, the subdomain that the user belongs to is found, and a PHP POST-call (through file_get_contents) is made to subdomain.domain.com/ajax/sub-login.php. This file validates and sets a SESSION.
- From the callback it looks like everything is done correctly, but the session is not set on subdomain.domain.com
I hope it makes sense. Any suggestions?