# Clear session after form has been submitted

**URL:** <https://forums.knack.com/t/clear-session-after-form-has-been-submitted/7121>\
**Category:** Get Answers\
**Created:** [April 13, 2018, 8:27pm UTC](https://forums.knack.com/t/clear-session-after-form-has-been-submitted/7121 "2018-04-13T20:27:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TannerClay98353](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@TannerClay98353](https://forums.knack.com/u/TannerClay98353)\
**Post date:** [April 13, 2018, 8:27pm UTC](https://forums.knack.com/t/clear-session-after-form-has-been-submitted/7121/1 "2018-04-13T20:27:31Z")

</div>

I have built a series of forms (Parent \> child \> child \> etc) as an e-commerce checkout. On the final step, payment is processed, and a number of Record Rules run that insert connected records. Occasionally, a user clicks the BACK button on their browser (I'm guessing this is what they do) and then RE-submits the form. Amongst other problems, it creates a duplicate payment record (and actually processes the card again).

Has anyone figured out a way to clear a form session (or something to this affect), after a form has been submitted, such that if a user clicks BACK on the browser, they won't be able to resubmit the form with the previously filled in session information?

---

<div class="post-metadata">

**Author:** ![ASOKAN](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@ASOKAN](https://forums.knack.com/u/ASOKAN)\
**Post date:** [April 26, 2022, 6:33am UTC](https://forums.knack.com/t/clear-session-after-form-has-been-submitted/7121/2 "2022-04-26T06:33:53Z")

</div>

I am also having the problem. Is there any solution for this?

---

<div class="post-metadata">

**Author:** ![KnackPros](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/knackpros/32/807_2.png) [@KnackPros](https://forums.knack.com/u/KnackPros)\
**Post date:** [May 2, 2022, 6:26pm UTC](https://forums.knack.com/t/clear-session-after-form-has-been-submitted/7121/3 "2022-05-02T18:26:51Z")

</div>

Try adding this code to your Custom JavaScript.

```auto
// Change view_100 to your form
$(document).on('knack-form-submit.view_100', function (event, view, record) {
  // Prevent the back button from returning to this form after it's submitted.
  window.history.replaceState({}, null, ' ')
})

```

This might help.

Ian  
[Knack Pros](https://knackpros.com)
