PHP Multi-Domain Sessions; ini_set Not Working?

后端 未结 3 644
南旧
南旧 2020-12-20 06:29

I\'m trying to set it up so if you log in to my website the session carries over to all sub-domains of my website. For example, if you go to domain.com and log in, then go t

3条回答
  •  清酒与你
    2020-12-20 07:10

    First verify the ini_set

     
    

    Update:

    Just thought about it.. Did you also try:

     
    

    Update 2: ALternate handling (manual cookie handling)

     
    

    and in the subdomain file

    "; 
    echo $_COOKIE['PHPSESSID'] . "
    "; echo session_id(); ?>

    Three lines you could add to every file to hand off / handle session info

    if (isset($_COOKIE['PHPSESSID']) && !empty($_COOKIE['PHPSESSID'])) session_id($_COOKIE['PHPSESSID']);
    session_start();  
    if (!isset($_COOKIE['PHPSESSID'])) setcookie('PHPSESSID',session_id(),time()+86400,'/','.domain.com');
    

    What info are you passing through the session? Or are you using it to handle logins, etc?

提交回复
热议问题