Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 14739
  • Last Modified:

Browser back button ("Warning Web Page has expired")

Hi all.
  I am developing an online shop and have hit a major hurdle.  Although I have got "back buttons" on my pages, and buttons which guide the user to where they should go, I still have the issue of users ignoring these buttons and simply pressing back in their browsers.  I have tried various things such as sending :
header("Cache-Control: public");
header("Cache-Control: max-age=" . $this->allowcache_expire * 60);
headers to prevent the problem, but nothing works as a valid solution.  The pages are all coded in PHP (although this is kind of irrelevant as it is the HTML output that poses my problems).  Also, the pages dont use "input type=submit" buttons - rather "input type=image".
I am fully aware that I cannot disable the browsers back button, but I know there is a solution to my problem.  For example, the british online bank (Natwest.com) uses a combination of "post" and "gets" all on encrypted (ssl) pages, yet it works fine when I press the browser back button.  All I want to do is have it so my pages do not show the "Warning web page has expired" warning, yet redraw correctly when back buttons are pressed.  

Any advice will be appreciated.

Richard

0
ricurtis
Asked:
ricurtis
2 Solutions
 
seanpowellCommented:
One possibility would be to add the following in your pages:

<script language="javascript" type="text/javascript">
<!--
   history.forward()
//-->
</script>

Trying to click on the back button to get to a page that this is on will simply move the hostory forward 1 step, and keep them on the same page.

From a UI perspective, you need to decide if preventing a user from going back is necessary for the application to be successful...
0
 
apparitionCommented:
One other technique would be to use location.replace. This makes sure that the link is not stored in the browsers history
and thus clicking on the back button on the browser dos not take you to the previous page.

example
<A onclick="location.replace("bla.html")"></a>
0
 
NetwingCommented:
I think you cant solve this problem because if anyone has set his or her browser to 0 Cache or "always reload" there will be always the "..web page has expired" message. This is a Browser broplem and you cant fix it with scripts.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Nelson_PiresCommented:
All your problems are related to buffer, in ASP we use (Response.Buffer = True) this will get the form input in place when the user backs/forwards, you need to find the equivalent in PHP and off you go.

Alternatively you could set the Script.Timeout to a higher value, again you need to find the PHP equivalent.

Hope it helps.
0
 
ricurtisAuthor Commented:
I am not convinced the Response.Buffer=True is the solution.  The php equivalent is ob_start(); but this is all server side - the problem I have is client side.  
Basically,(as far as my understanding goes - which could be wrong), in ASP all that Resonse.Buffer = True does is prevent any data actually getting sent to the client until the page has been completely rendered on the server.

I am beginning to think that when using "posts" for form data, there is probably no way to be able to do what I want.  The thing that annoys me is that I know of the one website which DOES use posts, and for them, all the pages work fine when you press the back button.  I think I might just have to live with the messages appearing - after all, if the users use the site as it is designed, there is no need to press the back button.
0
 
NetwingCommented:
I've saud it before.... your problem is on the browser side, and you can't do anything against it. Sometimes the backbutton works fine sometimes not... it depends on the browser settings.
0
 
Nelson_PiresCommented:
Ahh, I see your problem now, there's another easy way to stop the page has expired prob, use SSI (<!--#echo var="HTTP_REFERER"-->) to find out wich page they come from, on the pages you don't want people to go, then on the top of those pages make a comparason and if they have come from a forward page, send them back there, before the expiration message appears.

Like this:

You have page1, page2, and page3, on top of page1 you add the SSI to check if the user came from page2 or page3, if so, send them back there, if not, continue with the page, on page2 check only if they came from page3, easy.

You can also use xSSI like this:

<!--#if expr="${HTTP_REFERER} =/http/" -->
     <B>You came from <!--#echo var="HTTP_REFERER"--></B>
    <!--#else -->
      <B>I don't know where you came from</B>
  <!--#endif -->

Hope it helps.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now