Laravel: share session data over multiple domains
If you want to share the session between multiple subdomains in that case you have to set the domain name config/session.php has set the domain name.
Example: if you have new.example.com and test.example.com so you have to set the domain name as example.com
'domain' => env('SESSION_DOMAIN_URL','.example.com')
Solutions there worked for me, specifically setting the domain and then clearing my browser cookies & cache.
- Capture the session id
Session::getId()
in Domain A - send the captured session id via HTTP POST to Domain B
- Access the sent session id in domain B
$sessionid_from_domainA = $_POST['session_from_A']
- Set session in domain B
Session::setId($sessionid_from_domainA)
- Start Session in domain B
Session::start()