I would like to implement operations that is undoable in a short time after the user have done them. I.e. if a user upvotes a photo in a photo-site, he/she can undo the vote within 30 seconds. This is similar to how the voting on StackOverflow is working, you can undo your votes for a short time.
How should I implement it? I guess that I shouldn't commit the votes to the database before the delay has timed out, for performance reasons. And it's hard to do it in JavaScript because then is the vote lost if the user change website before the delay has timed out. Maybe I could do it in cookies, or maybe the best solution is to do it in PHP Sessions, but How do I commit the operation after the delay then?