go ahead... be a heretic | |
PerlMonks |
Re: CGI and Sessionsby dorward (Curate) |
on Jul 31, 2006 at 14:26 UTC ( [id://564747]=note: print w/replies, xml ) | Need Help?? |
Sessions probably aren't the best solution for this. In the more general case of protecting against duplicate submissions, I suggest that when you send the form to the client, you include a hidden input containing a unique pseudo-random string (perhaps some combination of the time, the user's ip address and a random number). Add this to a new column in your database. When the form is submitted, test to see if that value is already in the database. If it is, then you can either update the record or ignore the new data. In the specific case of dealing with refreshes, use the PRG pattern.
If the user hits refresh, then they'll just request the GET data again and not repost the submission.
In Section
Seekers of Perl Wisdom
|
|