Every time you generate the form (I suppose you do that in php),
generate inside the form a html line that says
<input type="hidden" value="$random" />
Thanks a lot,
No I dont generate the form, its a page with a form that they get to after checking availability etc with database and php.
Yes you are correct, its good to recognize them after payment also,
what I do is to us ipn and I update database as paid, and I run a chronjob that checks every 15 minutes if some booking has statement unpaid for more than 30 minutes.
What happens when they cancel the payment they goes to my cancelpage without being recognized, and the cron job deletes the booking.
As I said before, if I store the id of the booking I can delete the booking immediately if they come to cancelpage or if they clicks on hitback.
So I would store in the session the id of the booking, and the random value also, but one would be enough I think.
Hmm
on verification page (page between form and paypal):
if submit form (or as you said, if free {create session then insert booking in database and redirect to paypal for payment}
else {delete booking and kill session.}
then if they click back to form the form is there to modify and book again if they wish.
However if the click backs are very quick, I suppose there is time to delete the booking and kill session.