Quickly prevent users from repost?

Axoliien

Senior member
Mar 6, 2002
342
0
0
I've looked around and can't find what I am looking for. I need a quick way to prevent users from performing a repost using the back button in their web browser to exemplify the need for protection from repost. I will eventually write a full-on script to create hashes and keys, but for now I just need something used for example, not for deployment usage.

Any help or ideas?

Thanks!
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
First thing you do when they post:

-check value of a session variable called lastPost (of course, it could be anything, you make it up)
-it has a timestamp and if it's less than X seconds in the past reject the submission
-otherwise, set lastPost to the current timestamp and allow them to continue

Or maybe I'm misinterpreting what you want (I was thinging just no reposts within a certain amount of time...)

If you have a set workflow and you absolutely do not want them to repeat part of it then this is something that should be built right into your workflow without too much extra trouble. More or less, you have some form of recorded state about where they are in the workflow which would include if they've posted form X already. If they post form X again, you're looking for form Y data and it should be obvious that that's not what you're getting. Then you either kick them up to form Y with an error message or do something else to punish them. I guess I'm more or less describing what you said you don't have time to do, but if designed in from the beginning, I don't think it'd be much extra work.

Does any of what I've said make sense? :p
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
This might work if you're using POST and a < form > to submit the data:

using javascript you can have a "submitted = 0 ; " line in your code outside of any function, then change it to 1 in a function called by OnSubit() for the < form >

(have the function called by OnSubit() return false if the value is already == 1 )
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
The problem with that is that if they go back and then forward again, the javascript will start fresh. To a degree, it's also placing application security in the hands of the user and his/her browser with is a "Bad Thing."