How do I use cookies across two different domains?

前端 未结 5 763
既然无缘
既然无缘 2020-11-27 05:21

I need to share SSO information between two different domains with a cookie, can this be done in PHP and how?

5条回答
  •  野性不改
    2020-11-27 06:06

    I'm not sure about the security implications, but there is an Apache setting that allows you to change the domain of a cookie.

    # in httpd.conf (or equivalent)
    php_value session.cookie_domain mydomain.com
    

    I have successfuly employed this method for subdomains, but have never attempted for different domains.

    There is also a method to set the variables direction in PHP described at http://us.php.net/manual/en/function.session-set-cookie-params.php. The documentation makes no reference to the ability or inability to set cookies on a different domain.

    There is a different Stack Overflow thread on this same topic, but I don't think it was ever sufficiently answered.

提交回复
热议问题