From b0f9cfae1ec76b470622432278e909d08e745e15 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 12 Nov 2017 11:45:47 +0100 Subject: [PATCH] session timeout management in views: warehouse, admin + if no response, logout just .5min after the session timeout --- public_html/index.php | 11 ++++------- public_html/view/warehouse.php | 2 ++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/public_html/index.php b/public_html/index.php index 0fde11e..cffc38d 100755 --- a/public_html/index.php +++ b/public_html/index.php @@ -121,17 +121,14 @@ // session timeout echo "\n\t},\n"; echo "\tsession: {\n"; - echo "\t\ttimeout: '".( (ini_get('session.gc_maxlifetime')+$session_warn*60) * 1000 )."'\n"; + echo "\t\ttimeout: '".( (ini_get('session.gc_maxlifetime')-$session_warn*60) * 1000 )."'\n"; echo "\n\t}\n"; echo "};\n\n"; // {3} Function that reloads or logout the user echo "var KEEP_SESSION = function(keep){\n"; - echo "\tif( keep )\n"; - echo "\t\tdocument.location = '';\n"; - echo "\telse\n"; - echo "\t\tdocument.location = '/logout';\n"; + echo "\tdocument.location = ( keep ) ? '' : '/logout';\n"; echo "};\n\n"; // {4} Function called at session timeout @@ -141,7 +138,7 @@ echo "\tvar popup = new Popup();\n"; echo "\tvar popup_content = {\n"; echo "\t\ttitle: 'Expiration de connexion',\n"; - echo "\t\tcontent: 'Vous n\'avez rien fait depuis un moment. Vous serez déconnecté dans 5 minutes. Vous pouvez recharger la page pour garder votre connexion.',\n"; + echo "\t\tcontent: 'Vous n\'avez rien fait depuis un moment. Vous serez déconnecté dans ".round(.5+$session_warn)." minutes. Vous pouvez recharger la page pour garder votre connexion.',\n"; echo "\t\ttype: 'search',\n"; echo "\t\taction: 'Recharger la page'\n"; echo "\t}\n"; @@ -150,7 +147,7 @@ echo "\tpopup.ask(popup_content, KEEP_SESSION);\n"; // {4.3} Logout by default 5min if no popup response - echo "\tsetTimeout(function(){ KEEP_SESSION(false); }, $session_warn*60*1000);\n"; + echo "\tsetTimeout(function(){ KEEP_SESSION(false); }, (.5+$session_warn)*60*1000);\n"; echo "};\n\n"; diff --git a/public_html/view/warehouse.php b/public_html/view/warehouse.php index 6625b82..be8243c 100755 --- a/public_html/view/warehouse.php +++ b/public_html/view/warehouse.php @@ -22,6 +22,8 @@ + +