: This article mainly introduces thinkphp second-level domain name site session sharing (single sign-on). If you are interested in PHP tutorials, refer to it. Add the following code to index. php file for each second-level domain name website entry
Define ('domain ', 'cdfanfan. com'); // change cdfanfan.com to the actual root DOMAIN name
// The following two lines are used to share the SESSION of the subdomain. Note that the DOMAIN must be changed to the actual root DOMAIN name.
Ini_set ('session. cookie_path ','/');
Ini_set ('session. cookie_domain ', DOMAIN );
Change the session storage location of each second-level domain name site to shared storage: for example, mysql
Add 'session _ type' => 'DB' to the configuration file of each second-level domain name site ',
Mysql joins the table ocenter_session, and the table prefix ocenter _ needs to be modified according to the environment
Create table 'ocenter _ session '(
'Session _ id' varchar (255) not null,
'Session _ expire 'int (11) not null,
'Session _ data' blob,
Unique key 'session _ id' ('session _ id ')
)
The above introduces thinkphp second-level domain name site session sharing (single sign-on), including content, hope to be helpful to friends interested in PHP tutorials.