How do you prevent a user from posting data multiple times on a website

前端 未结 7 1097
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-08 16:30

I am working on a web application (J2EE) and I would like to know the options that are available for handling a double post from the browser.

The solutions that I ha

7条回答
  •  执念已碎
    2020-12-08 17:03

    Two server-side solutions come to mind:

    1. Create one-time use "tokens" in a hidden form field. Once a token is used, it is deleted from whatever database or session context object you're storing it in. The second time, it's not accepted.
    2. Cache information received, and if an identical form is received within a certain time period (10 minutes? an hour? You decide!) it is ignored.

提交回复
热议问题