Solved

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

Posted on 2003-12-01
7
14,387 Views
Last Modified: 2012-05-04
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
Comment
Question by:ricurtis
7 Comments
 
LVL 31

Accepted Solution

by:
seanpowell earned 100 total points
ID: 9850907
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
 
LVL 5

Expert Comment

by:apparition
ID: 9852339
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
 
LVL 2

Assisted Solution

by:Netwing
Netwing earned 25 total points
ID: 9858971
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Expert Comment

by:Nelson_Pires
ID: 9866451
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
 

Author Comment

by:ricurtis
ID: 9867309
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
 
LVL 2

Expert Comment

by:Netwing
ID: 9867611
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
 

Expert Comment

by:Nelson_Pires
ID: 9869950
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now