PHP session sharing between sub servers

Hello, I am trying to share session data between 2 sub servers ( sub domains) but it does not seem to work. I have created a php files in 2 different sub server in same domain with following codes:

ex1.example.com
<?php
session_start();
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
var_dump($_SESSION);

ex2.example.com
<?php
session_start();
var_dump($_SESSION);

second sub domain shows empty array.

How can I fix this?
Thank you.

I don’t think that’s supposed to be possible? Databases can be shared and I guess you could do something to load up the same session based on the ID, but the browser doesn’t really make that easy. I’m not an expert on this so maybe someone else will chime in…googling took me to this:

I think it is possible to share session data in same domain. Just need to figure out the correct way to do it.

Check your php.ini: