The front-end user fills in the value of the verification code picture when registering, and then matches it with the back-end.
However, because the user is not registered and cannot be tied with an identification, my temporary design is as follows:
When generating a verification code picture, the value of the verification code is stored in a inside of a cache, the cache sets an expiration time, and then the front end redis the value from the cache inside when submitting the verification code to see if there is a match and deletes the cache if there is a match.
The problem is that it is possible to lose the match and win the match, but the probability is not particularly high.
Is there a better idea?
If the front and back ends are separated, the verification code can be stored in the session for verification.
If the front end and the back end are separated, then each request from the front end is stateless, then a token needs to be assigned to the front end when the front end requests for the first time, and then the front end will carry the token with it every time it requests. You can use this token as the key value of redis and place the verification code in the corresponding value position.