Avoid credit recharge when clicking "back"

Hi I am a beginner in programming and this is a beginner’s theoretical question:

Say you create a charging form from scratch (charge.php). The customer pays for the products while in “charge_process.php” and then get a JS popup “You have been charged, don’t click “Back” or else you will get double rebilled”.

How can you avoid a case that it will get double rebilled when clicking back anyway? If I understand correct, the first step it is usually being done is redirecting the customer to a third page (thank_you.php or something of the sort) but I don’t know what else and can’t tell if it’s more of a JS solution in that stage:

  1. charge.php > process.php > thank_you.php
  2. ?

Well, you most definitely want to not rely on JavaScript for this.

It’s one thing giving a “need your ____” type of message to help the user, but never use it alone for security or anything else critical in nature.

I think for this, a SESSION would work. i.e. once the “cart” has been submitted, destroy the SESSION

eg. various “product” pages check for / set SESSION
→ “cart review” submit page, check for SESSION but do not set it if it doesn’t already exist
→ “thank you” page, destroy SESSION

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.