PHP Sessions across sub domains

前端 未结 17 1670
慢半拍i
慢半拍i 2020-11-22 05:59

I am trying to set up the following:

auth.example.com
sub1.example.com
sub2.example.com

If the user visits sub1.example.com or

17条回答
  •  余生分开走
    2020-11-22 06:29

    I can't speak for other versions of PHP, but in 5.6.6, simply setting the session.cookie_domain value in the php.ini file did the trick to allow all of my subdomains on iPage to share the same set of session variables.

    Be sure to remove any existing cookies related to your domain from your browser to test.

    session.cookie_domain = '.yourdomainname.example'
    

    Oh, don't know if it makes any difference but I'm also using session autostart.

    session.auto_start = 1
    

提交回复
热议问题