Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Clearing _GET and _POST

    Hi, I'm making a system which uses _GET and _POST a lot, but I don't want anything to mess up if I or someone else presses 'back' on their browser (or something like that).

    Is there a way to 'clear' _GET and _POST only if the user got to the page in a different way?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Nope, you can't stop a retransmit for a back button. All that really matters is likely a post though.
    You can use tokens for this. Simply create a token when a form is accessed and save it in a session, it can be anything random. When they submit the form, consume the token and respond accordingly. If they hit back and explicitly retransmit the post data, then the token is no longer available to be consumed, so don't react to the input. Since they repost the same data, the token provided by the form will not match if a new token is created or if there is no token to use at all.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •