Jump to content

best strategy to prevent BACK BUTTON from messing up shopping cart quantities


Recommended Posts

trying to figure out how to handle this scenario:

 

***

say i have 5 items in a shopping cart and hit a button to delete them all. i will then be shown a shopping cart with 0 items(or any empty cart message)... but if i hit the BACK BUTTON in my browser the shopping cart would still show 5 items in it...

***

 

what strategy could be used to get around this? is there something that could force the page to refresh once it's loaded? or a way to make the page pull in the proper quantity whether it's being loaded or reached by the back button?  ???

 

thanks.

Store values in _session.

 

Create a refresh after something significant happens (check-out, for example).

<html><head><meta http-equiv="refresh" content="0; url=index.php"></head></html>

 

Dont know how a "no-cache" system would work, but tehre's something like that.

 

Since never worked on a shopping cart system, cant really say mutch.

What exactly is the problem with the old items showing up when you hit the back button? Does it just show the old response sent by the server (the old page) or does it resend the request and re-process (so that the items are actually re-added)?

If the back button is just turning up old cached browser data, don't worry about it. That's a per-browser/user/client preference, something you probably oughtn't mess with.

If it's reprocessing it, do something like Gath said, with a redirection. Another method for redirection would be to alter the header's location after some sort of form processing:

header("Location: index.php");

Essentially does the same thing as the meta-refresh. Only thing is, you have to make sure that the header information is sent before the main body of it all is, so you'd need to do some organizing with your code.

Actually, a simple code would be to use javascript really. What you can do is add a php conditional to check to see if they clicked the "erase" button on the shopping cart, if they did, echo this out in the page before it...

 

<script language="javascript" >
history.go(1); /* auto-forces to go forward */
</script>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.