search
HomeBackend DevelopmentPHP Tutorialucenter synchronous login mechanism_PHP tutorial

Most friends who are engaged in PHP development know that there is ucenter, which can be used to log in and log out of multiple sites at the same time, and synchronize users. Next, the author will share with you how ucenter implements synchronous login.

First of all, the site must introduce a client such as uc_client. Taking login as an example, an external function will be called first when logging in. uc_user_login under uc_client/client.php checks whether this user exists. If it is correct, continue to execute the login code. , detect this user process: according to how the user connects to uc (mysql or http post), and then use different functions to detect the user accordingly. After the detection is completed, local login is implemented, the code is written by oneself, and then other applications are also logged in. , at this time the external function uc_user_synlogin is called, the process is as follows:

Uc_user_synlogin calls uc_api_post to implement which module to use. For example, it is the user module now, and the parameter passed is user_id. I don’t look at the details of how this is implemented. In short, the data is sent to uc_api, which is your ucenter address. index.php, and also attaches some parameters. Based on these parameters, it reads all the communicable applications in it and allows them to log in. This is a matter for other programs.

Notifying other applications mainly uses ucenter to send some data to api/uc.php under each application. The data is received by uc.php and then performs corresponding login operations.

This is what I wrote. It’s basically the same as his. I wanted to write down every function in detail but I’m a little tired today. Haha, it’s easy to find it yourself.

1. Start with user xxx entering the user name and password in login.php of a certain application. First use the uc_user_login function to verify the user and password on the uc server. If correct, write the session, write cookies, and update the login IP and login time in the application membership table. The user cannot feel this process.

2. Then notify the uc server through uc_user_synlogin that user xxx has successfully logged in. This process may use ajax, and the user will not feel the notification process.

3. After receiving this message, the uc server immediately ordered its subordinates to send the xxx login message, like a token ring, to all other applications that are willing to receive this message (whether the synchronous login is enabled in the background). In fact, it is to access the uc.php of each application with parameters, and the user cannot feel this process.

4. Each application relies on uc.php under the API to receive messages from the uc server, obey the instructions of the uc server, and do whatever it asks. Now, after receiving the command for user xxx to log in to your program, 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 cannot feel this process.

5. Finally, all programs integrated with uc, xxx logged in successfully. After the user logs in from www.phpernote.com/bbs, the login is also displayed when jumping to www.phpernote.com/. Because both the bbs and news systems are logged in in the background.

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

Articles you may be interested in

  • How to remove ads from dedeCMS background login page
  • php Output Control In-depth understanding of the difference between ob_flush and flush
  • It is dangerous for multiple URLs on a website to access the same content
  • The difference between synchronous requests and asynchronous requests in http requests
  • JS setInterval and setTimeout usage analysis
  • Solution to the "Invalid parameter encountered" error that pops up when CuteFTP connects to the ftp server
  • The usage and difference of using break, continue, goto, return, exit to jump out of multiple loops in PHP
  • mysql The usage differences between tinyint, smallint, int and bigint types

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764139.htmlTechArticleMost friends who are doing PHP development know that there is a ucenter that can be used to log in to multiple sites at the same time and log out at the same time, and user synchronization function. The author below will explain how ucenter implements synchronous login...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
解决win11中同时播放耳机和音响的问题解决win11中同时播放耳机和音响的问题Jan 06, 2024 am 08:50 AM

一般来说,我们只需要同时使用耳机或者音响的其中一个设备,但是有些朋友反映在win11系统中,遇到了耳机和音响一起响的问题,其实我们可以在realtek面板中将它关闭,就可以了,下面一起来看一下吧。win11耳机和音响一起响怎么办1、首先在桌面上找到并打开“控制面板”2、进入控制面板,在其中找到并打开“硬件和声音”3、然后再找到一个喇叭图标的“Realtek高清晰音频管理器”4、选择“扬声器”再点击“后面板”进入扬声器设置。5、打开之后我们可以看到设备类型,如果要关闭耳机就取消勾选“耳机”,如果要

您同步的文件夹中的一个或多个项目不匹配Outlook错误您同步的文件夹中的一个或多个项目不匹配Outlook错误Mar 18, 2024 am 09:46 AM

当您在您的同步文件夹中发现一个或多个项目与Outlook中的错误消息不匹配时,这可能是因为您更新或取消了会议项目。这种情况下,您会看到一条错误消息,提示您的本地数据版本与远程副本存在冲突。这种情况通常发生在Outlook桌面应用程序中。您同步的文件夹中的一个或多个项目不匹配。若要解决冲突,请打开这些项目,然后重试此操作。修复同步的文件夹中的一个或多个项目不匹配Outlook错误在Outlook桌面版中,当本地日历项与服务器副本发生冲突时,可能会遇到问题。不过,幸运的是,有一些简单的方法可以帮助您

MySql的数据迁移和同步:如何实现多台服务器之间的MySQL数据迁移和同步MySql的数据迁移和同步:如何实现多台服务器之间的MySQL数据迁移和同步Jun 15, 2023 pm 07:48 PM

MySQL是一个非常流行的开源关系型数据库管理系统,广泛应用于各种Web应用、企业系统等。在现代业务的应用场景下,大多数的MySQL数据库需要部署在多台服务器上,以提供更高的可用性和性能,这就需要进行MySQL数据的迁移和同步。本文将介绍如何实现多台服务器之间的MySQL数据迁移和同步。一.MySQL数据迁移MySQL数据迁移指的是将MySQL服务器中的数

教你如何将win10剪贴板与手机同步教你如何将win10剪贴板与手机同步Jan 06, 2024 am 09:18 AM

win10剪贴板有个非常好用的功能就是跨设备云储存功能,非常的好用可以帮助用户PC设备和手机设备同步复制黏贴。设置的方法非常简单,只要在系统里的剪切板设置就好。win10剪贴板同步到手机1、首先点击左下角的开始,进入设置。2、然后去点击“系统”。3、选择左侧的“剪贴板”。4、最后在右边的“跨设备同步”中点击登录,然后选择手机就好了。

如何在 Windows 11 的 OneDrive 中选择要同步的特定文件夹如何在 Windows 11 的 OneDrive 中选择要同步的特定文件夹Apr 13, 2023 pm 04:22 PM

您系统上的 OneDrive 应用程序将所有文件和文件夹存储在云端。但有时用户不希望某些文件或文件夹被存储并占用限制为 5 GB 的 OneDrive 空间而无需订阅。为此,OneDrive 应用程序中有一个设置,允许用户选择要在云上同步的文件或文件夹。如果您也在寻找这个,那么这篇文章将帮助您在 Windows 11 系统的 OneDrive 中选择要同步的文件夹或文件。如何在 Windows 11 的 OneDrive 中选择要同步的某些文件夹注意:确保 OneDrive 应用程序已连接并同步

百度云同步盘怎么同步百度云同步盘怎么同步Feb 23, 2024 pm 01:22 PM

百度云同步盘怎么同步?百度云同步盘中可以选择文件来同步,但是多数的用户不知道如何同步百度云文件,接下来就是小编为用户带来的百度云同步盘同步方法图文教程,感兴趣的用户快来一起看看吧!百度云同步盘怎么同步1、首先进入电脑桌面,右键点击【百度云同步盘】图标,选择【设置】;2、之后展开服务小窗口,切换到【高级设置】页面点击【选择文件夹】;3、最后切换到下图的页面,勾选需要同步的文件点击【确定】即可。

Python 并发编程中的锁与同步:保持你的代码安全可靠Python 并发编程中的锁与同步:保持你的代码安全可靠Feb 19, 2024 pm 02:30 PM

并发编程中的锁与同步在并发编程中,多个进程或线程同时运行,这可能会导致资源争用和不一致性问题。为了解决这些问题,需要使用锁和同步机制来协调对共享资源的访问。锁的概念锁是一种机制,它允许一次只有一个线程或进程访问共享资源。当一个线程或进程获得锁时,其他线程或进程将被阻止访问该资源,直到锁被释放。锁的类型python中有几种类型的锁:互斥锁(Mutex):确保一次只有一个线程或进程可以访问资源。条件变量:允许线程或进程等待某个条件,然后获取锁。读写锁:允许多个线程同时读取资源,但只允许一个线程写入资

emmo日记如何同步emmo日记如何同步Feb 27, 2024 pm 06:16 PM

Emmo是一款出色的日常生活记录软件,它提供了智能的记录功能和各种实用工具,帮助你详细记录生活中的点点滴滴。如果你想全面记录每天发生的事情,Emmo绝对是你的不二之选。通过这款软件,你可以在手机上轻松完成每天的日记,而且功能非常全面,满足你的各种需求。那么很多用户们还不清楚emmo日记中究竟该如何同步自己的日记,让大家在不同的设备中都能续写日记,想要了解的玩家们就快来跟着本文继续阅读吧。emmo心情日记怎么同步?1、点击左下角的菜单键2、登录你的账号3、退回到主界面,点击右上角的云朵按钮4、点击

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.