PHP Cookies for multiple Domains

前端 未结 5 1748
野的像风
野的像风 2020-12-09 06:54

I want to create a cookie from one domain once the user is registered in PHP. and make this cookie accessible to 4 other domains not subdomain. I know that cookies are not d

5条回答
  •  [愿得一人]
    2020-12-09 07:21

    I had solved exactly same problem (actually also for 4 domains). The only solution I've came up with was, to include 3 hidden iframes on the 'Successful login page' and those iframes just load www.domain1.com/register_session.php, www.domain2.com/register_session.php, etc....

    As a parameter for register_session.php I use 'sid' which contains session ID:

    session_id($_GET['sid']);
    session_start();
    

    This is actually for keeping session alive on all those domains but the same would be for your case with cookies.

提交回复
热议问题