donboe — 2010-06-30T00:07:28-04:00 — #1
I have a simple shopping cart (Arrays and Structures). When someone have checked out the come on a age with their order information and a cfmail is send with that order information. I just found out that when I refresh the page the cfmail is send again (this time without order details since I also clear the structure on this page) Is there a way to prevent the cfmail from being send twise?
Thank you all
system — 2010-06-30T16:28:58-04:00 — #2
There's no 100% sure way to prevent users from hitting refresh/back. But a few thoughts are
- Add some validation so mails are only sent if there is information to process ie the cart is not empty.
- After the mail is sent, and cart cleared, redirect users to a confirmation page. Then it won't matter if they refresh
- Set a session variable that keeps track of order confirmations already sent. Then check it before sending an email.