Some ideas resubmit the form and distributed verification code

And some ideas from their online finishing, non-original.

1. Form to repeat
the form submission is repeated a plurality of times in a short period of time a user request, and response to background processing has not completed then the next request. Program: one is the pretreatment, the other is processing on the server side.

 Distal: definition of a mark, no click is false, then click ture set, first determine the time of submission. If false, the program is executed, the isClick set to true, it said that it has clicked, and then after a commit, background success or failure response before this value is reset to false, if isClick is ture does nothing directly return .

 Background: In the initial page when backstage pass to uniquely identify the page, while the token is stored or cached in the session, after the form is submitted, a token comparison, equal representation for the first time submitted, business processes, and then delete the session in the token . If the token is not shown in the session duplicate submission, the business process is not performed, you can resubmit prompt return to the page.

 

2. Distributed server code storage problem

Traditional solutions: generate time codes into the session, when the comparison authentication.

Cluster program: to generate codes when producing a logo into the page, while the unique identifier as a key, as the value verification code into redis, set the verification code survival time, when the form is submitted to the background, holding a token to get redis code comparison, regardless of the verification is successful or not, so that the current token failure.

 

Guess you like

Origin www.cnblogs.com/llhhll/p/11202077.html