There is session data being saved on sub.domain.com
and I'd like to use that data in domain.com
.
I confirmed that they both have the same session save path (by echoing ini_get('session.save_path')
in both)
I've tried putting ini_set('session.cookie_domain', '.sub.domain');
on domain.com but that didn't work. (I have also removed the preceding .
).
I also tried adding session_set_cookie_params(0, '/', '.domain.com');
in front of each session_start()
, but that didn't work either.
I would like to be able to use the $_SESSION
data in domain.com
from what is set in sub.domain.com
.
What can I do for this to work?
Thanks!
UPDATE: I figured out (at least one way) of how to do this, but not sure why my answer works. I guess my question would now be, Why does renaming the session name solve this? using the same session cookie domain (?) makes more sense to me.
Seems like setting this domain creates a new session
$_SESSION['domain']
(where 'domain' is interchangeable in the session_name('domain')
function.)