Link to home
Start Free TrialLog in
Avatar of ricurtis
ricurtis

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of seanpowell
seanpowell
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apparition
apparition

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>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of ricurtis

ASKER

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.
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.
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.