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