Sharing php Session ($_SESSION) across multiple domain

后端 未结 5 1061
轻奢々
轻奢々 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 09:08

    Considering your original question and your answers to Logan and myself in the comments of the original question I understand:

    1 - you want to pass the session variables among a domain and its subdomains; and

    2 - CI and Symfony load the session before you have a chance to do the ini_set command.

    I believe you have two options:

    1 - include the php configuration command in the php.ini file

    session.cookie_domain=".foo.com"
    

    If you try including it in the .htaccess it will not work if you are running php as a CGI module, which seems to be fairly common among shared hosting services.

    2 - you can prepend a file to all php scripts in your site. Those will be put on top of every single php script your site runs, even the ones inside CI and Symfony. For example:

    phpprepend.php file

    
    

    include the following line in your php.ini file:

    auto_prepend_file = "/path/to/file/phpprepend.php"
    

    Please let us know if this solves the problem.

    Good luck!

提交回复
热议问题