1

When a user logs out I'm trying to suppress the back button from rendering the previous page. The code seems to work but I notice on a iphone the previous page is displayed for a second or two before it's replaced with the logon screen. Is there a way to prevent that?

Here's the JS I'm using in the form

 window.onpageshow = function(event) {
     if (event.persisted) {
        window.location.reload() 
     }
 };

and then in the control file I simply use:

if(!isset($_SESSION['id']))  
    redirect("login.php");  

I also tried the iframe solution but found that didn't work at all:

<iframe style="height:0px;width:0px;visibility:hidden" src="about:blank">
    this frame prevents back forward cache <!--doesn't work -->
</iframe>
DCR
  • 14,737
  • 12
  • 52
  • 115

1 Answers1

0

You might try the following (suggested elsewhere, e.g. https://stackoverflow.com/a/9783386)

document.body.style.display = "none"; // insert this line, before the next
window.location.reload();
Community
  • 1
  • 1
Chris
  • 4,212
  • 5
  • 37
  • 52