php - adjust logout function to handle safari back button issue -


i have following logout() function works on browsers not safari. problem in safari after logout if user hits button previous page cache instead of login screen. there way adjust logout function handle this?

function logout() {        // unset session variables     $_session = [];      // expire cookie     if (!empty($_cookie[session_name()]))     {        // setcookie(session_name(), "", time() - 42000);        $params = session_get_cookie_params();                    setcookie(session_name(), '', time() - 42000,                  $params["path"], $params["domain"],                  $params["secure"], $params["httponly"]);     }      // destroy session     session_destroy();         } 

it seems me browser issue more server issue.

  1. have tried configuring caching headers in order disallow caching of logged pages ?

  2. as other solution, found post in relation: preventing cache on back-button in safari 5 .

you try solution putting javascript in logged pages:

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

to reload page after logout check there no cookie, such button still work when logged in instance. change "yourcookiename" string session cookie name.

function getcookie(cname) {     var name = cname + "=";     var ca = document.cookie.split(';');     for(var i=0; i<ca.length; i++) {         var c = ca[i];         while (c.charat(0)==' ') c = c.substring(1);         if (c.indexof(name) == 0) return c.substring(name.length, c.length);     }     return null; }  function hascookie(cname) {      return getcookie(cname) !== null; }  window.onpageshow = function(event) {     if (event.persisted && !hascookie("yourcookiename")) {         window.location.reload(); // or redirect login page     } }; 

note: think cache still exists in safari solution 2. so, not solution handling correctly security in opinion.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -