slushpuppie Posted October 12, 2007 Share Posted October 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
Gath Posted October 12, 2007 Share Posted October 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
deadimp Posted October 13, 2007 Share Posted October 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
kratsg Posted October 13, 2007 Share Posted October 13, 2007 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.