PHP was separated anterior and posterior. How to do login verification code

for items that are separated before and after, a CAPTCHA is required when logging in. I have also thought about using account login times and ip login restrictions to sit, but I feel that there is no CAPTCHA. But the front and back ends are separated and there is no answer mechanism, so how to use the picture verification code-sharp-sharp-sharp problem description

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Php
Jul.20,2021

pictures can also be made into interfaces


1. The front end generates a random number-"access the CAPTCHA interface
2. The backend puts the values of the random number and CAPTCHA into redis
3. When the front end submits the login, the random number and CAPTCHA are submitted to the backend to compare the random CAPTCHA.


session exists in the backend controller of the login interface. It is displayed in the form of a picture at the front end. When submitted, it is compared with the verification code in session, and can be released after success.


isn't there a cookie? Cookie can save a unique id


an image corresponds to a unique random number, and the
backend implements a session-like function with its own cache.


Front-end separation does not affect the back-end generation of session.

when entering the login page, the back end returns session_id to the front end, and the front end stores session_id to maintain the session.

when the front end requests the verification code, the session_id is sent to the backend, and the back end generates the verification code and stores the answer to the verification code in the SESSION where the front end sends the session_id. When verifying the verification code, the front end also sends the session_id. The back end compares the verification code stored in the SESSION corresponding to the session_id, and remember to delete the verification code stored in the session after the verification is passed.

Menu