session timeout management in views: warehouse, admin + if no response, logout just .5min after the session timeout

This commit is contained in:
xdrm-brackets 2017-11-12 11:45:47 +01:00
parent 0faaee0040
commit b0f9cfae1e
2 changed files with 6 additions and 7 deletions

View File

@ -121,17 +121,14 @@
// session timeout // session timeout
echo "\n\t},\n"; echo "\n\t},\n";
echo "\tsession: {\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\t}\n";
echo "};\n\n"; echo "};\n\n";
// {3} Function that reloads or logout the user // {3} Function that reloads or logout the user
echo "var KEEP_SESSION = function(keep){\n"; echo "var KEEP_SESSION = function(keep){\n";
echo "\tif( keep )\n"; echo "\tdocument.location = ( keep ) ? '' : '/logout';\n";
echo "\t\tdocument.location = '';\n";
echo "\telse\n";
echo "\t\tdocument.location = '/logout';\n";
echo "};\n\n"; echo "};\n\n";
// {4} Function called at session timeout // {4} Function called at session timeout
@ -141,7 +138,7 @@
echo "\tvar popup = new Popup();\n"; echo "\tvar popup = new Popup();\n";
echo "\tvar popup_content = {\n"; echo "\tvar popup_content = {\n";
echo "\t\ttitle: 'Expiration de connexion',\n"; echo "\t\ttitle: 'Expiration de connexion',\n";
echo "\t\tcontent: 'Vous n\'avez rien fait depuis un moment. Vous serez déconnecté dans <b>5 minutes</b>. 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 <b>".round(.5+$session_warn)." minutes</b>. Vous pouvez recharger la page pour garder votre connexion.',\n";
echo "\t\ttype: 'search',\n"; echo "\t\ttype: 'search',\n";
echo "\t\taction: 'Recharger la page'\n"; echo "\t\taction: 'Recharger la page'\n";
echo "\t}\n"; echo "\t}\n";
@ -150,7 +147,7 @@
echo "\tpopup.ask(popup_content, KEEP_SESSION);\n"; echo "\tpopup.ask(popup_content, KEEP_SESSION);\n";
// {4.3} Logout by default 5min if no popup response // {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"; echo "};\n\n";

View File

@ -22,6 +22,8 @@
<script type='text/javascript' src='/js/lib/min/api.js' ></script> <!-- Gestion des transactions avec le serveur --> <script type='text/javascript' src='/js/lib/min/api.js' ></script> <!-- Gestion des transactions avec le serveur -->
<script type='text/javascript' src='/js/lib/min/page-manager.js' ></script> <!-- Gestion des transactions avec le serveur --> <script type='text/javascript' src='/js/lib/min/page-manager.js' ></script> <!-- Gestion des transactions avec le serveur -->
<script type='text/javascript' src='/serverinfo.js' ></script> <!-- Gestion dynamique des info server -->
</head> </head>
<style type='text/css'> <style type='text/css'>
body{ body{