I know this is an old thread, just want to share, what worked for me.
I have managed to get this working on localhost (sub1.domain.localhost, sub2.domain.localhost), but could not make it work on shared hosting on live site. So I compared the phpinfo() on local and live site. Turns out the difference was that the site on shared hosting was storing php session in memcache.
This solved it for me:
$config->sessionCookieDomain = '.domain.tld';
$config->sessionCookiePath = '/';
ini_set('session.save_handler', 'files');
ini_set('session.save_path', __DIR__ . '/assets/sessions');
ini_set('session.cookie_domain', $config->sessionCookieDomain);