Using browser back button

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Using browser back button

Post by haagen »

Often when I have written a page in php i can't use the back- and forward button in the browser. I think it have something to do with a http-header sent to the client. But I haven't figgured it out yet.

Someone care to explain how it works and how I can prevent this?
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

Post by 9902468 »

when you push the back button what does it say?

warning! page is expired perhaps

or does the page just stop functioning correctly (Something is lost)

or or or

more details please

-9902468
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Post by haagen »

Right. The message is that the page has expired.
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

Post by 9902468 »

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0

Then, you must send one of these headers?

either you get rid of those, (not recommended) or you accept that user can sometimes get that message. I really haven't educated myself enough that I could tell what you must do, but dynamic webpages are not supposed to be cached, as they might have changed. (But user can't see changes because page is loaded from old cache...)

hope that helped

-9902468
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

some of these things might also be held in <meta> tags
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Post by haagen »

Thanks. Now I have something more to go on. 8)
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

It can happen when you using session I think.. but it might not.
Post Reply