Click "receive red envelopes" in the menu. The rule is to click at most one red envelope at a time. now the problem is that sometimes two red envelopes can be caught at a time, so that merchants cannot lose money. what I did previously was filter through database records, I got a red packet online database entry record, but it was useless. then I thought about it... click "receive red envelopes" in the menu. The rule is to click at most one red envelope at a time. now the problem is that sometimes two red envelopes can be caught at a time, so that merchants cannot lose money. what I did previously was filter through database records, I got a red packet online database entry record, but it was useless. then I tried to pass the session. for each user, I received a red packet and sent it to a session to clear the session, in this way, there will be no two identical red packets for users, but the session has not been tested. What are the best solutions ??
Reply content:
Click "receive red envelopes" in the menu. The rule is to click at most one red envelope at a time. now the problem is that sometimes two red envelopes can be caught at a time, so that merchants cannot lose money. what I did previously was filter through database records, I got a red packet online database entry record, but it was useless. then I tried to pass the session. for each user, I received a red packet and sent it to a session to clear the session, in this way, there will be no two identical red packets for users, but the session has not been tested. What are the best solutions ??
Click it to execute a function. the function is used to receive a red packet. it is impossible to implement this function twice if it gets stuck?
If the SESSION is used, if the user receives the red packet, clears the COOKIE, and then receives the red packet again, the same user may receive the packet multiple times.
We recommend that you use apsaradb for redis to store the user information that has received red packets. This prevents users from clearing the cookies and refreshing the red packets.
You can use the token to hide the domain.
Verify the token when requesting a red envelope, and delete it after the verification is successful.
Cannot trust input from the client