Sharing php Session ($_SESSION) across multiple domain

后端 未结 5 1064
轻奢々
轻奢々 2020-12-06 08:53

I have 2 different domain, let\'s call them www.foo.com and bar.foo.com. The first one is built with CI, and the second one is built with Symfony. I want to share my session

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 08:59

    You need to set up the session cookie's domain so that it is accessible from both sites.

    Either add that to both sites's PHP code very early on in loading, or add something like this to your .htaccess file in both sites.

    php_value session.cookie_domain ".foo.com"
    

    I'm not 100% sure the second options works, but I think it should.

提交回复
热议问题