Today's website background login page needs to generate a QR code, and then scan the QR code on the mobile app to achieve the website login effect and the following solutions

Source: Internet
Author: User

To realize the two-dimensional code login, need to solve 2 technology, 1, the need for JS WebSocket and background PHP to achieve long-connection technology

2, realize the two-dimensional code generation technology

To achieve this function the second is relatively simple, only need to download a PHP two-dimensional code generator can be, but to achieve long-connection technology, through the multi-check data, there are 2 ways 1 is nodejs to achieve back-end services, the other is to use a PHP extension swool to achieve background services, This example uses the latter swool,

The first step, when you open the login page, using PHP to generate a unique sign, using JS WebSocket technology to connect to the background service, and sign to the background service, while using sign to generate two-dimensional code

The second step, backstage service after receiving this sign, the sign and the store socket client side of the third step, the use of the app-side QR Code tool to scan the QR code, the activity of a string generated by signs, and the string and the current login user information, through the interface call passed to the background

Fourth step, the server interface received the information, the sign and user information to do the check, check error, after sending the socket message to the background service, the background service received a message to find the corresponding client, and send a message to the client, confirm the login

Fifth Step, Login page received confirmation of login message, upload to sign to login page

The sixth step, the PHP login page after receiving sign, verify signs, OK login

Today's website background login page needs to generate a QR code, and then scan the QR code on the mobile app to achieve the website login effect and the following solutions

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.