Ajax cross-domain implementation of single sign-on

Source: Internet
Author: User

Requirements: The same root domain name or the same domain name of two domain names, to achieve a single sign-on logout

Principle:

Take B station as an example, B station's account login domain name is passport.bilibili.com. The main station is www.bilibili.com, the game station is www.biligame.com,

Get login user Information interface for http://api.bilibili.com/nav?callback=jQuery17209622933453583296_1497257608944&type=jsonp&_= 1497257609114,

1. User access www.bilibili.com or www.biligame.com, if not logged in, the user click the login button to jump to passport.bilibili.com for login processing, while setting the bilibil.com domain login information cookie (dedeuse RIDs and DEDEUSERID__CKMD5)

2, user access to www.bilibili.com or www.biligame.com, if logged in state, according to Cookie information (Dedeuserid and DEDEUSERID__CKMD5), the head asynchronously based on the user information interface load login information, The user information with JS rendering to the head, while setting the user information for the global JS variable, convenient for other needs to determine the location of login calls.

Core technology: Www.biligame.com Station uses the Ajax JSONP way to request api.bilibili.com information across domains, bringing the api.bilibili.com cookie information that the browser itself carries over. So www.biligame.com does not need to use the user's cookie

Ajax cross-domain implementation of single sign-on

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.