Php shares the session between the primary domain name and the secondary domain name and performs single-point logon.

Source: Internet
Author: User
In fact, it is relatively easy to implement multi-level second-level domain names using cookies or sessions in php at the same time. let's take a look at an example below. the company website has several second-level domain names. the boss requires that no matter which domain name the member goes to, the primary domain name or second-level domain name, the user... in fact, it is relatively easy to implement multi-level second-level domain names using cookies or sessions in php at the same time. let's take a look at an example below.

The company website has several second-level domain names. the boss requires that users log on to the website regardless of the domain name, primary domain name, or second-level domain name that the member has visited, and do not need to log on again. Obviously, single sign-on is required.

Php can be implemented in two ways. the cookie is used to save the session_id. each domain name can access the cookie to obtain the session_id:

1. use the session_set_cookie_params () method:

Session_set_cookie_params (0, $ path, 'phprm. com ');

2. use ini_set or modify php. ini to modify the value of session. cookie_domain:

Ini_set ('session. cookie_domain ', 'phprm. com ')

Permanent address:

Reprint at will ~ Please bring the tutorial URL ^

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.