


UCenter single sign-on/synchronous login/synchronous logout instance_PHP tutorial
ucenter I think many friends will use it. It is a member synchronization function. We often integrate several systems or different forums. Let me introduce it to you.
UCenter synchronization process:
The premise is that you need to add applications that require simultaneous login on Ucenter (at least 2 to see the effect), and display: Communication successful
Suppose I add two application websites A and B
1. First, when site A logs in, after the login is successful, the essence of the process is to call the method provided by uc_client to obtain two script codes (sites A and B) from UCenter. These two script codes are to access A and B. The login method in the website's api/uc.php can be used to perform the session and cookie operations required for login.
2. When logging out, the operation is the same as logging in. You need to obtain 2 script codes from UCenter. The purpose is to trigger the logout method in api/uc.php of stations A and B.
Important: After obtaining the two script codes, you must let the browser run in the output, otherwise synchronous login and logout will not be realized.
Suggestion: When developing and debugging, use browser monitoring to check the return output value. I was using chrome F12 and then opened the Network tab.
Detailed examples
The so-called single sign-on is nothing more than several sites sharing a user center to achieve synchronous login and synchronous logout.
Server side: Loog SSO
Customer service: ucenter, to be honest, the commercialization of dz has indeed made PHP develop a lot.
ucenter basic principle:
In fact, it is the user who logs in in the end, but the user will not notice it if ajax is used.
Let’s take a look at the specific procedures with ucenter:
config.php [PHP code]:
The code is as follows | Copy code | ||||
define(‘UC_DBHOST’, ’localhost’); // UCenter database host define(‘UC_DBUSER’, ’root’); // UCenter database user name define(‘UC_DBPW’, ’123′); // UCenter database password define(‘UC_DBNAME’, ’ucenter’); // UCenter database name define(‘UC_DBCHARSET’, ’utf8′); // UCenter database character set define(‘UC_DBTABLEPRE’, ’ucenter.uc_’); // UCenter database table prefix define(‘UC_KEY’, ’safefewfef’); // The communication key with UCenter must be consistent with UCenter define(‘UC_API’, ’http://www.bKjia.c0m/uc’);// URL address of UCenter, relying on this constant when calling the avatar define(‘UC_CHARSET’, ’utf-8′); // UCenter’s character set define(‘UC_IP’, ’127.0.0.1′); // The IP of UCenter. When UC_CONNECT is in non-mysql mode and the current application server has problems resolving the domain name, please set this value define(‘UC_APPID’, ’3′); // Corresponds to the ID of ucenter’s current application define(‘UCDOMAIN’,’http://www.bKjia.c0m/’); // Domain name settings //Some Cookie Settings $_UC = array(); $_UC["cookiedomain"] = ”; // cookie scope $_UC["cookiepath"] = ’/’; // Cookie action path $_UC["cookiepre"] = ’uc_’; // cookie prefix $_UC["cookietime"] = ’31536000′; //cookie action time |
After the configuration file is written, add an application in the ucenter backend. Remember to customize the ‘UC_KEY’ which must be the same as in config.php
The next step is api/uc.php in your home directory
For example, if the application url is filled in as http://www.bKjia.c0m, then I will have the corresponding http://www.bKjia.c0m/api/uc.php
If you want to customize, please confirm your corresponding relationship.
The most important thing is api/uc.php. Synchronous login is to access uc.php of each application. Dz has already given a demo for this
[PHP code]:
代码如下 | 复制代码 |
define(‘API_DELETEUSER’,0); //note 用户删除 API 接口开关 define(‘API_RENAMEUSER’, 0); //note 用户改名 API 接口开关 define(‘API_GETTAG’, 0); //note 获取标签 API 接口开关 define(‘API_SYNLOGIN’, 1); //note 同步登录 API 接口开关 define(‘API_SYNLOGOUT’, 1); //note 同步登出 API 接口开关 define(‘API_UPDATEPW’, 0); //note 更改用户密码 开关 define(‘API_UPDATEBADWORDS’, 0); //note 更新关键字列表 开关 define(‘API_UPDATEHOSTS’, 0); //note 更新域名解析缓存 开关 define(‘API_UPDATEAPPS’, 0); //note 更新应用列表 开关 define(‘API_UPDATECLIENT’, 0); //note 更新客户端缓存 开关 define(‘API_UPDATECREDIT’, 0); //note 更新用户积分 开关 define(‘API_GETCREDITSETTINGS’, 0); //note 向 UCenter 提供积分设置 开关 define(‘API_GETCREDIT’,0); //note 获取用户的某项积分 开关 define(‘API_UPDATECREDITSETTINGS’, 0); //note 更新应用积分设置 开关 |
These parameters are function switches provided to other applications
Finally, how to log in to other applications simultaneously with your own page
[PHP code]:
The code is as follows
|
Copy code
|
||||
include_once ’../uc_client/client.php’;
Your verification login section |
http: //www.bkjia.com/PHPjc/632783.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



1. How to buy WeChat reading membership cheaply? Share the best way to buy membership on WeChat Reading! 1. Open the WeChat Reading APP. There is a reading challenge in the reading welfare special session. Participate in the reading challenge. 2. Pay 1 yuan to participate, read for 7 days, duration >7 hours, and get a 4-day paid membership card with 4 book coins. You can participate for about 52 weeks in a year. If you participate every time, it will cost a total of 52 yuan, and you can get a total of 208 days. Paid membership card 208 book coins. 3. Pay 3 yuan to participate, read for 14 days, duration >14 hours, and get a 10-day paid membership card with 10 book coins. You can participate about 26 times a year. If you participate every time, it will cost a total of 78 yuan, and you can get a total of 260 days. Paid membership card costs 260 book coins. 4. Pay 4 yuan to participate and read for 21 days

When you log in to someone else's steam account on your computer, and that other person's account happens to have wallpaper software, steam will automatically download the wallpapers subscribed to the other person's account after switching back to your own account. Users can solve this problem by turning off steam cloud synchronization. What to do if wallpaperengine downloads other people's wallpapers after logging into another account 1. Log in to your own steam account, find cloud synchronization in settings, and turn off steam cloud synchronization. 2. Log in to someone else's Steam account you logged in before, open the Wallpaper Creative Workshop, find the subscription content, and then cancel all subscriptions. (In case you cannot find the wallpaper in the future, you can collect it first and then cancel the subscription) 3. Switch back to your own steam

With the rapid development of social media, Xiaohongshu has become a popular platform for many young people to share their lives and explore new products. During use, sometimes users may encounter difficulties logging into previous accounts. This article will discuss in detail how to solve the problem of logging into the old account on Xiaohongshu, and how to deal with the possibility of losing the original account after changing the binding. 1. How to log in to Xiaohongshu’s previous account? 1. Retrieve password and log in. If you do not log in to Xiaohongshu for a long time, your account may be recycled by the system. In order to restore access rights, you can try to log in to your account again by retrieving your password. The operation steps are as follows: (1) Open the Xiaohongshu App or official website and click the "Login" button. (2) Select "Retrieve Password". (3) Enter the mobile phone number you used when registering your account

QQ Music is a music-listening software used by many users. Some songs here require users to have membership before they can download and play them. So how to get QQ Music membership for free? Let this site give users a detailed introduction to the tutorial on how to obtain QQ Music membership for free. Tutorial on getting QQ Music membership for free 1. First, we open QQ Music. 2. Go to my homepage and click on the three horizontal lines in the upper right corner. 3. Click to open the free music listening mode here. 4. A 15-second advertisement will appear here. We only need to wait for the advertisement to end to get a thirty-minute membership experience. Experience time can be superimposed. 5. Obtain a membership after reading it. Receive 1 day of QQ music

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 cancel automatic membership renewal on Kugou Music APP? There are many users who have applied for Kugou Music’s VIP auto-renewal service. Later, they want to cancel this service, but they don’t know where to cancel it. Below, I will bring you a tutorial on how to cancel the auto-renewal of Kugou Music. I hope it will be helpful to everyone. . It is very simple to cancel automatic renewal in Kugou Music APP: just enter the member center, find the music package/luxury VIP option, select automatic renewal enabled, and then click to close renewal. 2. WeChat: As shown in the picture below, go to the payment page, click the three dots in the upper right corner, select the deduction service, click Kugou Music to close the service; 3. Alipay: Go to the settings page, select payment settings, and select password-free payment/ Automatically deduct fees, and finally choose Kugou Music to terminate the contract.

How to cancel the automatic renewal of Zhihu app membership? Zhihu app is a very practical mobile software. This software has many functions, and each function will bring a different feeling to the users. There are some contents on this software that require users to register as a member before they can read them. Membership on this software is not expensive, and continuous monthly membership will be cheaper. Some players want to know how to cancel automatic renewal. The editor below has compiled methods for canceling automatic renewal for your reference. How to cancel automatic renewal for Zhihu app members Zhihu members can choose four renewal methods, including Apple Pay, WeChat Pay, Alipay Pay and Baidu Pay. For users who choose Baidu Pay, renewal can be managed through WeChat or Alipay payment.

Bilibili is a video playback platform with rich resources, including a dance area, ghost animal area, food area, animal area, etc. But now many times you need to be a member to watch videos on site B. If you don’t want to spend money, can you get a member of site B? The editor here will bring you how to get the free membership of Bilibili. I hope it can help you. How to get free membership on Bilibili: Open Bilibili and click "My". Click the "Creation Home" icon in the "Creation Center" area. After entering the creation center, click "Task Center". After entering the task center, read the corresponding tasks and complete them to get points.
