Laravel 4: Prevent form re-submissions

社会主义新天地 提交于 2019-12-05 18:37:30

The Shift Exchange:

Are you sure your browser is not 'refreshing' the page when it presses 'back' - because of 'no-cache'? Try this: load the form, view the source, look @ the hidden token code. Then submit the form, press back, and @ look at the hidden token code - are they the same?

Trying Tobemyself Rahu:

no they aren't the same

Then that is your answer! Your browser is 'refreshing' the page when you are pressing 'back'!

So your code 'works' for most browsers - but whichever browser you are using is automatically refreshing the page on the 'back' - thus your token is being repopulated on the form. It is as is the user is 'revisiting' the form - so there is little you can do to stop this. It will work for most browsers...

Or you can turn off the 'no-cache' for the form - or set it to like 5mins or something - so the browser will not refresh the page.

Maybe have a 'form' cache filter - which is 5mins and a filter for all the other site - which is 0, something like that would be 'Laravel elegant' :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!