Simple analysis Ucenter member Synchronous login Communication principle, Ucenter Communication principle _php Tutorial

Source: Internet
Author: User

Simple analysis Ucenter member Synchronous login Communication principle, ucenter communication principle


1, the user login discuz, through the logging.php file function Uc_user_login to post data verification, that is, username and password to verify.

2. If the validation succeeds, the function uc_user_synlogin in the client.php file under Uc_client will be called, in which uc_api_post (' user ', ' synlogin ', Array (' uid ' = > $uid)).

3. The function then passes the data to the Ucenter index.php, index.php accepts the transmitted data and obtains the value of the model User,action as Synlogin.

4. Then Ucenter's index.php calls the Onsynlogin method in the User.php class in the control directory, which, through the Foreach Loop, notifies the UC app list in a JavaScript-enabled app to log on synchronously, which is passed to each uc.php some data under the API in the directory.

5, uc.php receive notification and processing get over the data, and in the function Synlogin (in uc.php) through the function _authcode encrypt the data (by default, Uc_key as the key), with the function _setcookie set the cookie.

6, each application uses the corresponding key to decode the cookie set above, to obtain the user ID and other data; This value is used to determine whether the user has been logged in through other applications, allowing users to log on automatically.

The logging.php of the application------>uc_client in client.php------>ucenter------> api/uc.php in other applications.

In fact, ucenter implementation of the principle of synchronous landing is a cookie, a successful application after landing, to Ucenter pass data, let Ucenter notify other applications also set cookies, so that users access to other applications through the set of cookies to achieve automatic landing.

Roughly, first install ucenter and then copy the Uc_client folder into your own project, then configure several files

client.php equivalent to a library of functions

uc.php equivalent to callback file

Config.php is a configuration file

When you have 2 apps that are set up for sync login when you log in to an app and then execute

Include './config.inc.php ';
Include './uc_client/client.php ';
$usernames = "Kyee";
$passwords = "123456";
List ($uid, $username, $password, $email) = Uc_user_login ($usernames, $passwords);
if ($uid > 0) {

Setcookie ("username", $username, Time () +intval (24*3600));
echo Uc_user_synlogin ($UID);
Echo ' login success ';
} elseif ($uid = =-1) {
Echo ' user does not exist, or is deleted ';
} elseif ($uid = =-2) {
echo ' password error ';
} else {
echo ' undefined ';
}

Uc_user_synlogin () This function represents a synchronous login to all other functions that enable simultaneous login. UC itself will be in the background to all the applications that enable synchronization to loop through and then output on the page

Similar to this kind of JS code, is sent to each open sync login application, and then each open Sync login application callback file uc.php will be decrypted after the decryption, you can actually write your own code, this uc.php callback file code does not have to follow their format to write, You can also write your own code yourself.

In fact, the principle of UC is very simple, is an application login, and then the background polling sent to the application of synchronous login callback file, callback file received the user ID, generate a cookie or session and then enter the login mode.


Ecshop+discuz Ucenter integration shows successful communication but no member synchronization is possible rewarded

Please check whether you are allowed to sync members, login Uncenter backstage. Application Management-ecshop Configuration!

Ucenter implementation of synchronous landing, you need to read data from the database to determine whether the login success?

1, user login discuz, through the logging.php file function uc_user_login The post data validation, that is, username and password to verify.

2, if the validation succeeds, the function uc_user_synlogin in the client.php file under Uc_client is called, in which uc_api_post (' user ', ' synlogin ', Array (' UID ' = $uid)).

3, the function then passes the data to the Ucenter index.php, index.php accepts the passed data, obtains the value that the model is user,action to Synlogin.

4, Then Ucenter's index.php calls the Onsynlogin method in the User.php class in the control directory, which, through the Foreach Loop, notifies the UC app list in a JavaScript-enabled app to log on synchronously, which is passed to each uc.php some data under the API in the directory.

5, uc.php receives notifications and processes get-over data, and in function Synlogin (located in uc.php) through the function _authcode encrypt data (by default, Uc_key as the key), with the function _setcookie set the cookie.

6, each application uses the corresponding key to decode the cookie set above, to obtain the user ID and other data, through this value to determine whether the user has been logged in other applications, so that users can automatically log in.

Application logging.php------>uc_client in client.php------>ucenter------> Application api/uc.php

In fact, ucenter implementation of the principle of synchronous landing is a cookie, a successful application after landing, to Ucenter pass data, let Ucenter notify other applications also set cookies, so that users access to other applications through the set of cookies to achieve automatic landing. Understand the principle of ucenter synchronization, and then encountered the inability to log in, or develop some interface with the Ucenter will be much easier.
 

http://www.bkjia.com/PHPjc/869451.html www.bkjia.com true http://www.bkjia.com/PHPjc/869451.html techarticle Simple Analysis Ucenter member Synchronous login Communication principle, ucenter Communication principle 1, User login discuz, through the logging.php file function Uc_user_login to post data to verify, ...

  • 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.