Table of Contents
您可能感兴趣的文章
Home php教程 php手册 ucenter同步登陆机制

ucenter同步登陆机制

Jun 13, 2016 am 09:36 AM
Synchronize Login

做php开发的朋友大都知道有个ucenter可以用来实现多个站点同时登陆同时退出,用户同步的功能。下面作者将要就ucenter是如何实现同步登陆的和大家做一下分享。

首先站点都要引入一个uc_client这样一个客户端,以登陆为例,登陆时首先会调用一个外部函数,uc_client/client.php下的uc_user_login检查是否存在此用户,如果正确则继续执行登陆代码,检测此用户过程:通过用户是以什么方式连的uc(mysql还是http post)然后去相应地用不同函数来检测用户,检测完成后实现本地登陆,代码自己写,然后让其他应用程序也登陆,此时调用外部函数uc_user_synlogin,过程如下:

Uc_user_synlogin调用uc_api_post来实现是要做哪个模块,比如现在就是user模块,传的参数是user_id,具体这是怎么实现的没再仔细看,总之是将数据发送到uc_api即你的ucenter地址的index.php,同时附一些参数,根据这些参数然后再去读里面所有可通信的应用程序,让他们也实现登陆,这是其他程序的事儿了。

通知其他应用程序主要是通过ucenter,去向各应用程序下的api/uc.php发送一些数据,这些数据由uc.php接到请求然后去执行相应的登陆操作等。

这是我写的,基本上和他的一样,本想把具体到每个函数都写的可今天有点累了,呵呵,自己找吧还是很简单的。

1.从用户xxx在某一应用程序的login.php,输入用户名,密码讲起。先用uc_user_login函数到uc server验证此用户和密码,如正确,则写入session,写入cookies,并更新应用程序会员表中的登录ip,登录时间。用户感觉不到这个过程。

2.然后通过uc_user_synlogin通知uc server 用户xxx登录成功,这个过程可能使用ajax,用户感觉不到通知过程。

3.uc server收到这个消息后,马上命令手下,把xxx登录的消息,像令牌环一样,发给所有愿意接收(后台中那个是否开启同步登录)这个消息的其它应用程序。其实就是带参数访问一下各应用程序的uc.php,用户感觉不到这个过程。

4.各应用程序靠api下的uc.php来接收uc server发来的消息,并对uc server言听计从,让干什么就干什么。现在,收到让xxx用户在你的程序中登录的命令,马上执行。并写本应用程序的session,并且使用p3p, 写入相同域或不同域的cookies.  用户感觉不到这个过程。

5.最后所有和uc整合的程序,xxx均登录成功。用户从www.phpernote.com/bbs登录后, 跳到www.phpernote.com/同样显示登录。因为bbs 和news系统在后台均已登录。

6.应用程序与uc server的会话结束。

您可能感兴趣的文章

  • 如何去除dedeCMS后台登陆页面的广告
  • php Output Control 深入理解 ob_flush 和 flush 的区别
  • 网站上多种url都能访问同样的内容是件危险的事
  • http请求中同步请求和异步请求的区别
  • js setInterval和setTimeout用法分析
  • CuteFTP连接ftp服务器时弹出“遇到无效的参数”错误的解决办法
  • PHP中跳出多重循环使用break,continue,goto,return,exit的用法和区别
  • mysql中tinyint、smallint、int和bigint类型的用法区别
Statement of this Website
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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PlayStation network login fails, but internet connection succeeds PlayStation network login fails, but internet connection succeeds Feb 19, 2024 pm 11:33 PM

Some players are experiencing a strange issue on PS4 or PS5 at launch. For example, this can cause distress when their PlayStation Network login fails, but their internet connection is fine. You may encounter errors when entering your login information and may not be able to join PSParty chat. If you encounter a similar problem, this guide may help you solve it. Next to PlayStationNetworkSign-in, you will see the error message ‘AnErrorHaveAreAre’ and it will say ‘Failure’. Other parameters like getting IP address, internet connection and connection speed were successful. So, what could be the problem here? I will give you a job

Fix AADSTS7000112, Application is disabled Microsoft account login error Fix AADSTS7000112, Application is disabled Microsoft account login error Feb 19, 2024 pm 06:27 PM

The AADSTS7000112 error may prevent you from logging into the app using your Microsoft account, causing you inconvenience. This article will provide you with solutions to help you resolve this issue and restore a normal login experience. Login: Sorry, you are having trouble logging in. AADSTS7000112: Application disabled. Fortunately, you can fix the error by following some simple suggestions. What is error code AADSTS7000112? Error code AADSTS7000112 indicates a problem with the connection to Microsoft's Azure Active Directory. Typically, this may be due to the Microsoft application trying to log in being blocked.

Solve the problem of playing headphones and speakers at the same time in win11 Solve the problem of playing headphones and speakers at the same time in win11 Jan 06, 2024 am 08:50 AM

Generally speaking, we only need to use one of the headphones or speakers at the same time. However, some friends have reported that in the win11 system, they encountered the problem of headphones and speakers sounding at the same time. In fact, we can turn it off in the realtek panel and it will be fine. , let’s take a look below. What should I do if my headphones and speakers sound together in win11? 1. First find and open the "Control Panel" on the desktop. 2. Enter the control panel, find and open "Hardware and Sound" 3. Then find the "Realtek High Definition" with a speaker icon. Audio Manager" 4. Select "Speakers" and click "Rear Panel" to enter the speaker settings. 5. After opening, we can see the device type. If you want to turn off the headphones, uncheck "Headphones".

One or more items in the folder you synced do not match Outlook error One or more items in the folder you synced do not match Outlook error Mar 18, 2024 am 09:46 AM

When you find that one or more items in your sync folder do not match the error message in Outlook, it may be because you updated or canceled meeting items. In this case, you will see an error message saying that your local version of the data conflicts with the remote copy. This situation usually happens in Outlook desktop application. One or more items in the folder you synced do not match. To resolve the conflict, open the projects and try the operation again. Fix One or more items in synced folders do not match Outlook error In Outlook desktop version, you may encounter issues when local calendar items conflict with the server copy. Fortunately, though, there are some simple ways to help

How to log in to corporate WeChat email How to log in to corporate WeChat email Mar 10, 2024 pm 12:43 PM

How to log in to the email address of Enterprise WeChat? You can log in to the email address in the Enterprise WeChat APP, but most users don’t know how to log in to the email address. Next is the graphic tutorial on how to log in to the email address of Enterprise WeChat brought by the editor for interested users. Come and take a look! Enterprise WeChat usage tutorial How to log in to the Enterprise WeChat email 1. First open the Enterprise WeChat APP, go to the [Workbench] at the bottom of the main page and click to come to the special area; 2. Then in the workbench area, select the [Enterprise Mailbox] service; 3. Then jump to the corporate email function page, click [Bind] or [Change Email] at the bottom; 4. Finally, enter [QQ Account] and [Password] on the page shown below to log in to the email.

MySql data migration and synchronization: How to achieve MySQL data migration and synchronization between multiple servers MySql data migration and synchronization: How to achieve MySQL data migration and synchronization between multiple servers Jun 15, 2023 pm 07:48 PM

MySQL is a very popular open source relational database management system that is widely used in various web applications, enterprise systems, etc. In modern business application scenarios, most MySQL databases need to be deployed on multiple servers to provide higher availability and performance, which requires MySQL data migration and synchronization. This article will introduce how to implement MySQL data migration and synchronization between multiple servers. 1. MySQL data migration MySQL data migration refers to the data migration in the MySQL server.

GeForce Experience login freezes [Fix] GeForce Experience login freezes [Fix] Mar 19, 2024 pm 06:30 PM

This article will guide you to solve the GeForceExperience login crash issue on Windows 11/10. Typically, this can be caused by unstable network connections, corrupted DNS cache, outdated or corrupted graphics card drivers, etc. Fix GeForceExperience Login Black Screen Before starting, make sure to restart your internet connection and computer. Sometimes, the problem may just be due to a temporary issue. If you are still experiencing NVIDIA GeForce Experience login black screen issue, please consider taking the following suggestions: Check your internet connection Switch to another internet connection Disable your

How to solve the problem of too frequent login operations on Wegame? How to solve the problem of too frequent login operations on Wegame? Mar 14, 2024 pm 07:40 PM

Wegame is a software used with Tencent games. You can use it to start games and gain acceleration. Recently, many users have experienced prompts that login operations are too frequent when using it. Faced with this prompt, many users do not know How can we solve it successfully? In this software tutorial, we will share the solution with you. Let’s learn about it together. What should I do if Wegame login operations are too frequent? Method 1: 1. First, make sure our network connection is normal. (You can try opening the browser to see if you can access the Internet) 2. If it is a network failure, then try restarting the router, reconnecting the network cable, and restarting the computer to solve the problem. Method 2: 1. If there is no problem with the network, then select &

See all articles