Ucenter synchronous login mechanism _ PHP Tutorial

Source: Internet
Author: User
Ucenter synchronous login mechanism. Most of my friends who are doing php Development know that there is a ucenter that can be used to achieve simultaneous login and exit of multiple sites and user synchronization. The following author will discuss how ucenter achieves synchronous login for php Development. most of my friends know that there is a ucenter that can be used to achieve simultaneous login and exit of multiple sites and user synchronization. The authors will share with you how ucenter implements synchronous login.

First, the website must introduce a client such as uc_client. for example, when logging on to the website, an external function uc_client/client will be called first. in php, uc_user_login checks whether the user exists. if the user is correct, continue to execute the login code and check the user's process: how the user connects to uc (mysql or http post) then, use different functions to detect users. after the detection is complete, implement local login, write the code by yourself, and then log on to other applications. at this time, call the external function uc_user_synlogin. The process is as follows:

Uc_user_synlogin calls uc_api_post to implement which module is to be implemented. for example, the user module is used now and the passed parameter is user_id. how can this problem be implemented, in short, the data is sent to uc_api, that is, the index of your ucenter address. php, also with some parameters, according to these parameters and then read all the communications applications in it, so that they can also achieve login, this is the case of other programs.

Other applications are notified to go to the APIs/uc under each application through the ucenter. php sends some data, which is produced by uc. php receives the request and then performs the corresponding login operation.

This is what I wrote, basically the same as him. I wanted to write everything into every function, but today it's a little tired. well, it's quite easy to find it by yourself.

1. start with the username and password of user xxx in login. php of an application. Use the uc_user_login function to verify the user and password on the uc server. if the password is correct, the session is written, the cookies are written, and the logon ip address and logon time in the application member table are updated. The user does not feel this process.

2. Then, use uc_user_synlogin to notify the uc server user xxx that the logon is successful. this process may use ajax and the user will not feel the notification process.

3. after receiving the message, the uc server immediately sends the xxx logon message to all users who are willing to receive it, like the starting ring (whether to enable synchronous logon in the background) other applications of this message. In fact, it is to access the uc. php of each application with parameters, and the user does not feel this process.

4. various applications rely on uc. php under the api to receive messages from the uc server and listen to the uc server. Now, you receive the command to allow xxx users to log on to your program and execute it immediately. And write the session of this application, and use p3p to write cookies in the same domain or different domains. the user does not feel this process.

5. all programs integrated with uc are successfully logged on to xxx. The user jumps from www.phpernote.com/bbs.pdf to www.phpernote.com/demo. Because the bbs and news systems have logged on to the background.

6. the session between the application and the uc server ends.

Articles you may be interested in
  • How to remove ads on the dedeCMS background login page
  • Php Output Control: Understanding the differences between ob_flush and flush
  • It is dangerous for multiple URLs on the website to access the same content.
  • Differences between synchronous requests and asynchronous requests in http requests
  • Analysis of js setInterval and setTimeout usage
  • When CuteFTP is connected to the ftp server, the "invalid parameters" error is displayed.
  • Use break, continue, goto, return, and exit in multiple loops in PHP
  • Differences in the usage of tinyint, smallint, int, and bigint types in mysql

Bytes. The authors will discuss how ucenter achieves synchronous login...

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.