avoid session timeout when user is active FR#1529
Signed-off-by: Smita Kumari <kumarismita62@gmail.com>
This commit is contained in:
parent
2b7ef3f31f
commit
42223e1bf6
@ -53,6 +53,9 @@ if (! empty($_REQUEST['target'])
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Check if it is an ajax request to reload the recent tables list.
|
||||
*/
|
||||
|
||||
@ -676,6 +676,60 @@ var last_clicked_row = -1;
|
||||
*/
|
||||
var last_shift_clicked_row = -1;
|
||||
|
||||
var _idleSecondsCounter = 0;
|
||||
var IncInterval;
|
||||
var updateInterval;
|
||||
AJAX.registerTeardown('functions.js', function () {
|
||||
clearInterval(updateInterval);
|
||||
clearInterval(IncInterval);
|
||||
});
|
||||
|
||||
AJAX.registerOnload('functions.js', function () {
|
||||
document.onclick = function() {
|
||||
_idleSecondsCounter = 0;
|
||||
};
|
||||
document.onmousemove = function() {
|
||||
_idleSecondsCounter = 0;
|
||||
};
|
||||
document.onkeypress = function() {
|
||||
_idleSecondsCounter = 0;
|
||||
};
|
||||
|
||||
function SetIdleTime() {
|
||||
_idleSecondsCounter++;
|
||||
}
|
||||
function UpdateIdleTime() {
|
||||
var href = 'index.php';
|
||||
var params = {
|
||||
'ajax_request' : true,
|
||||
'token' : PMA_commonParams.get('token'),
|
||||
'db' : PMA_commonParams.get('db'),
|
||||
'access_time':_idleSecondsCounter
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: href,
|
||||
data: params,
|
||||
success: function (data) {
|
||||
clearInterval(updateInterval);
|
||||
if (data.success) {
|
||||
if (PMA_commonParams.get('LoginCookieValidity')-_idleSecondsCounter > 5) {
|
||||
updateInterval = window.setInterval(UpdateIdleTime, (PMA_commonParams.get('LoginCookieValidity')-_idleSecondsCounter-5)*1000);
|
||||
} else {
|
||||
updateInterval = window.setInterval(UpdateIdleTime, 2000);
|
||||
}
|
||||
} else { //timeout occured
|
||||
window.location.reload(true);
|
||||
clearInterval(IncInterval);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (PMA_commonParams.get('logged_in')) {
|
||||
IncInterval = window.setInterval(SetIdleTime, 1000);
|
||||
updateInterval = window.setInterval(UpdateIdleTime, (PMA_commonParams.get('LoginCookieValidity')-5)*1000);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Unbind all event handlers before tearing down a page
|
||||
*/
|
||||
|
||||
@ -237,7 +237,9 @@ class PMA_Header
|
||||
),
|
||||
'LimitChars' => $GLOBALS['cfg']['LimitChars'],
|
||||
'pftext' => $pftext,
|
||||
'confirm' => $GLOBALS['cfg']['Confirm']
|
||||
'confirm' => $GLOBALS['cfg']['Confirm'],
|
||||
'LoginCookieValidity' => $GLOBALS['cfg']['LoginCookieValidity'],
|
||||
'logged_in' => isset($GLOBALS['userlink']) ? true : false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,11 @@ class AuthenticationConfig extends AuthenticationPlugin
|
||||
{
|
||||
// try to workaround PHP 5 session garbage collection which
|
||||
// looks at the session file's last modified time
|
||||
$_SESSION['last_access_time'] = time();
|
||||
if (isset($_REQUEST['access_time'])) {
|
||||
$_SESSION['last_access_time'] = time()- $_REQUEST['access_time'];
|
||||
} else {
|
||||
$_SESSION['last_access_time'] = time();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -554,8 +554,11 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
// Avoid showing the password in phpinfo()'s output
|
||||
unset($GLOBALS['PHP_AUTH_PW']);
|
||||
unset($_SERVER['PHP_AUTH_PW']);
|
||||
|
||||
$_SESSION['last_access_time'] = time();
|
||||
if (isset($_REQUEST['access_time'])) {
|
||||
$_SESSION['last_access_time'] = time() - $_REQUEST['access_time'];
|
||||
} else {
|
||||
$_SESSION['last_access_time'] = time();
|
||||
}
|
||||
|
||||
$this->createIV();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user