specificaly to block users from hitting the back button on their browsers.
This is really not the way to approach the problem. For one, it goes against accessibility/usability directives, for another, attempting to break the back button in all browsers is unreliable at best.
I do have a better one, and it shouldn't be all that difficult to implement, without trying to control user behavior.
The problem is that many customers hit the back button, going all the way to the begining of the proccess, select something different and procceed with the new rquest.
Since a unique id is already assigned to the customer, the new data overwrites the old ones.
Right. So here is what you do:
1. Add a field "completed" (or something) to your database, boolean or tinyint(1), defaults to false/0. On COMPLETION of the orders, update it to 1. Similar to your scenario B, if you add this as a new field and
set the default as false or 0,, it won't affect any other codings for the transaction complete field. You'd just need to chase it down at final completion.
2. If it's not there already, move or set it up so this
very first step in the process, or the very first time the id is inserted into the database, a new ID is generated every single time. Also at this point, be sure to unset any sessions or cookies that may be set so they are generated new:
if (isset($_SESSION['unique_id'])) { unset($_SESSION['unique_id']); }
3. Yes, this will create a lot of "dead records." The two easiest ways to manage it are a) cron or b) manual batch. Create a daily cron job to delete all records older than "today" with a completed status of 0:
delete from table where created <= date_sub(curdate(),interval 1 day) and completed=0;
I leave all records for "today" due to time differences, midnight, etc. If you like, you can keep them until they are two days old, if your user behavior tells you people leave their browsers open for days at a time (often happens on ecommerce sites.)
The second is to make that a manual update via any administrative area you have. The reason for using the second instead is it's good to look at "abandoned" orders or processes to get a feel for user behaviors.
Whatever you do, don't chase the back button disable, all paths lead to "not good". :-)