Javascript-web Scan Code Login How to realize, ask a thought

Source: Internet
Author: User
Recently in a Web instant messaging, there is a scan code login function. Have not done before, ask the experts to talk about.
such as QR code how to come, the web side if listening to the phone scan code success, and the server sent the data

Reply content:

Recently in a Web instant messaging, there is a scan code login function. Have not done before, ask the experts to talk about.
such as QR code how to come, the web side if listening to the phone scan code success, and the server sent the data

步骤       WEB平台                手机第1步      生成二维码第2步     (ajax监控后台)          扫码第3步     (ajax监控后台)          确定(后台异步通知WEB平台)第4步      AJAX发现状态改变,登陆成功

The process of Ajax monitoring backstage: After generating the QR code,

setTimeout(function(){    //AJAX请求,检测状态},5000);

The upstairs words are right. Let me Add.
Consider an example
Solve two problems,<1> the computer from the server to get someone to sweep my computer and authorize login.
Then the app, to solve is to sweep the after, know who swept the person who, the person to tell the information to the server.
Objects <1> Websites <2> mobile Phones Open

Process
<1>web generate links, links made into two-dimensional code, generally using local cookies or SessionID as the only parameter.

<2>app sweep, in fact, is to authorize the operation, crawl user information, the user information and the request contained in the cookie or SessionID stored in the library
<3>web every few seconds Ajax request backstage, query the current cookie or sessionid whether there is a corresponding login information, there is the login operation.

1. Front-end call backend generate QR Code API, get to QR code picture and the information contained (usually a unique ID)
2. Front-end detection (by polling or websock, choose) whether there is a mobile phone scan code, by invoking the background interface API, the parameter is the above unique ID
3. Mobile phone scanning QR code login, mobile phone can get to the QR code information ID, with the current login user ID and the ID of the QR code to call the background interface.
Background store this QR code data, plus login user information, the current station call API, to return login success.
4. Front-end acquisition to login successful, to jump

  • 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.