Thinkphp second-level domain name site session sharing (single sign-on)

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.