【PHP】Session共享

一、核心:redis接管Session
if(C('SESSION_TYPE')) { 
            $type   =   C('SESSION_TYPE');
            $class  =   strpos($type,'\\')? $type : 'Think\\Session\\Driver\\'. ucwords($type);
            $hander =   new $class();
            session_set_save_handler(
                array(&$hander,"open"),
                array(&$hander,"close"),
                array(&$hander,"read"),
                array(&$hander,"write"),
                array(&$hander,"destroy"),
                array(&$hander,"gc"));
        }

  

 
二、api.com域名
设置session
返回session_id
 
 
三、www.com域名
session_write_close();         # 暂停Session
session_id('api返回的session_id');     # 设置session_id
session_start();              # 这时候会从新的SessionId的缓存中读取数据
 
 
 
 
 

posted @ 2020-08-27 11:25  蓝色星辰1993  阅读(253)  评论(0编辑  收藏  举报