Thoughts on multi-domain name login Solutions

Source: Internet
Author: User
Tags cc domain

Scenario:

Currently, three domains, aa.com, bb.com, cc.com, and aa.com, are user centers, and login.aa.com are user center logon portals. Currently, you must log on to any domain. You do not need to log on to other domains again.

Solution:

We know that to ensure that all three domains are logged on at the same time, you must share the login information and login information, either stored on the client or on the server, to share this information, you must solve the problem of synchronizing the information under multiple domain names. Take the client as an example. I think there are two ways:

1) set a sub-domain of login.xx.com for the other two domains (this is set to facilitate management). When accessing any website and clicking login, log on to login.aa.com at the user center. After Successful Logon, set the logon status and verification information,

Write the information to the cookie of this domain. Domain = login.aa.com, all aa.com domains and subdomains can obtain the cookie value, and write the cookie value to the other two domains,

For example:

<SCRIPT src = "http://login.bb.com /? Type = setcookies & s = xxxxxxxxxxxxxxxxxxx ">

<SCRIPT src = "http://login.cc.com /? Type = setcookies & s = xxxxxxxxxxxxxxxxxxx ">

The encrypted login information can be directly stored in another domain in the form of jsonp,

In this way, the login and verification information of the user can be obtained for the other two domains and subdomains, so that the login and verification information of the user are no longer required under the two domain names.

Advantages:

Set the logon cookies in the logon area to facilitate unified management of cookie values and verification rules. Once you log on, other domain names do not need to be logged on again. When logging out, clear the cookie values that contain user information in each domain.

Disadvantages:

It is unpredictable whether other domains need to be added. If another domain name is added, We need to write the cookie value to this domain. If there are many domain names, the login time may be a little long, but it is better within five domain names. In general, it is not closed. Likewise,

Logging out is similar to processing multiple other domain names.

2) solution 2: when accessing any website, log on to the login.aa.com logon portal. After successful login, set the login user information and authentication information, and write the information to the cookie, domain: This is login.aa.com, And the cookie can be obtained from the sub-domain of AA.

Value, after successful login, and then execute Jump http://login.bb.com/login.php? Type = setcookie & value = xxxxxxxxxxxxxx & U = http://bb.com/test.html U for the jump Destination Address login.bb.com to analyze the value of this cookie for storage, then jump to the http://bb.com/test.html page, this page is already in the login status, this completes a login process, if in the cc.com page access, such as when accessing the http://cc.com/test.html, first, check whether the cookie value exists.

If the value does not exist, a jump request is sent to the http://login.aa.com/login.php? Domain = cc.com & U = Hangzhou,

Execute jump http://login.cc.com/login.php? Type = setcookie & value = xxxxxxxxxxxxxx & U = http://cc.com/test.html, login.cc.com analyzes the value of this cookie for storage, and then jumps to the http://cc.com/test.html page,

At this time, the page is logged on. This completes CC domain login and information sharing.

Advantages:

Controllable, shortening login time without affecting login. A new domain is added for easy operation.

Disadvantages:

When logging out, you must clear the cookie values in all domains.

You are welcome to make a brick. If you have a better solution, you are welcome to discuss it.

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.