Jump to content

Firefox 'Back' button breaks PHP cookie?


iwannabeleet

Recommended Posts

I have a cookie script which breaks when Firefox's BACK button is used, as Firefox displays the cached version and the PHP script is not re-run to check/modify the cookie.

 

I solved the problem by adding these headers to force the reload:

<?php
header("cache-Control: no-store, no-cache, must-revalidate");
header("cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

 

But I wanted to ask if anyone knows if there is a simpler solution to this? My concern is that these headers will cause Firefox to reload everything, including the media/images on the page (which seems excessive). Is there a better way to solve this problem?

 

Thank you for any advice/suggestions

Link to comment
Share on other sites

your script should check if cookies are valid on all pages, if the back button is pushed you can't do anything a bout it cause th at is loading a Local copy of the page if headers were sent processor pages should refresh and bounce to the according page (if they have a redirect) so if your processor is built to verify the cookie is set before resetting you should be all set/

Link to comment
Share on other sites

gotta remember that a browser is always displaying a local copy that is "cached" after the document is transported from server -> client.  The back button in most browsers is defaulted to display the cached data of the "last/back" page.

 

Thus why even if a huge process takes place on the previous page the back button only displays any valid output be it html, xml, txt, jpg etc. 

 

Now if that page is refreshed the client is requested new data and thus the processor will reoccur unless you put in some sort of security settings to prevent this so a user can't refresh say adding an event.

Link to comment
Share on other sites

  • 1 year later...

IE and Safari handle this correctly i.e. they recognise a cookie has been set when Back button is pressed and process accordingly. I've just come across the same problem and immediately checked other browsers to see if it was Firefox et al specific. Guess what? It is.

 

Rich

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.