Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions, postdata & browser "back" button...

Status
Not open for further replies.

admoore

IS-IT--Management
May 17, 2002
224
US
I have a site using PHP sessions for user authentication. When users ignore the "bread crumb" links to navigate backwards on the site and instead use the browser's back button, they get a browser pop-up similar to:

back_msg.jpg


Perhaps there is no way to prevent this behaviour when the user presses back instead of following the link to the previous page; but, if there is, any help in fixing this "feature" would be appreciated.

TIA,

-Allen
 
Nope, that is standard behaviour in all browsers I have encountered. It basically tells you it needs to resend the data to render the page again.

You can however avoid having duplicate submissions, by setting a Session variable and checking for it, if it is set it means that the form has already been submitted and you can redirect someplace else. If it is not set, then you can go ahead and do whatever it is needs to be done.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
From a comment on the php manual:


To force pages to always load the data that was entered in the form prior to hitting a submit button, and prevent the browser's cache message from displaying, use the following code:
Code:
<?php

   // Original code found at [URL unfurl="true"]http://www.mnot.net/cache_docs/[/URL]

   header("Cache-Control: must-revalidate");
   $offset = 60 * 60 * 24 * -1;
   $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
   header($ExpStr);

?>
This will tell the browser that the page will expire in one day, and the cached form data will be used without prompting the user at all.

Its worth a shot... please post back if this worked for you!

X
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top