PHP implementation of the main domain name and two-level domain name sharing session and single sign-on

Source: Internet
Author: User

The company's website set up a number of two domain names, the boss asked no matter which domain name the member went to, the main domain name or level two domain name, users are logged in state, and do not need to log in again.
Obviously, the requirement is a single sign-on.

There are two ways to do this in PHP, which is to save session_id with cookies, each domain name can access the cookie, and then get the session_id:

1. Use the Session_set_cookie_params () method:

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

2. Modify the Session.cookie_domain value by using Ini_set or modifying the php.ini:

Ini_set (' Session.cookie_domain ', ' abc.com ')

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.