php - Stopping the back button from exposing secure pages? -


i'm encountering (apparently common) problem browser caches, , secure pages being accessible via button (after user logout.)

here logout.php

<?php     // 1. find session      session_start();      // 2. unset session variables     $_session = array();      // 3. destroy session cookie     if(isset($_cookie[session_name()])) {         setcookie(session_name(), '', time()-42000, '/');     }      // 4. destroy session     session_destroy();      redirect_to('index.php?logout=1'); ?> 

this logs out users on ie7, ie8, chrome , firefox--but in safari, i'm able press button (immediately after logging out) , still see secure content. if refresh secure page, boots me login screen (as should.)

you can try @ http://labs.inversepenguin.com (user: stack & pass: overflow.)

i've tried using:

<meta http-equiv="pragma" content="no-cache"> <meta http-equiv="expires" content="-1"> 

...but has no effect. can offer advice? i've found this article on browser caching, have yet find answer within it... although did find:

<?php  header("cache-control: must-revalidate");   $offset = 60 * 60 * 24 * 3;  $expstr = "expires: " . gmdate("d, d m y h:i:s", time() + $offset) . " gmt";  header($expstr); ?> 

...which not solve "problem." hmm.

if can use https, combined cache-control: no-cache header disable "page cache" (the webkit term in-memory/back-forward cache). downside of disabled secure page views, not after log out. (source; note working on allowing exceptions, it's worth keeping eye on this.)

if can depend on javascript, attaching unload event handler prevent "page cache". has benefit of allowing break cache when "log out" button or link clicked, attaching unload event handler. (source)

neither of these solutions ideal, 1 of them might worthwhile compromise.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -