问题
Currently the Admin session in OpenCart is about 30 seconds. I was wondering is there a PHP file or is there some way I can increase the timeout session for the login?
Currently I have been told this solution works but it does not:
<script type="text/javascript">
function pingServer() {
$.ajax({ url: location.href });
}
$(document).ready(function() {
setInterval('pingServer()', 60000);
});
</script>
This file has been placed in admin/view/template/common/header.tpl
回答1:
This can most likely be solved simply by changing the value of session.gc_maxlifetime
. You can change this via .htaccess, php.ini or even in your script itself (before the session_start()
)
回答2:
I've been having the same problem with a client and have used the above suggestion because changing session.gc_maxlifetime was not working. If the user leaves the admin page open using the above method, it will never get timed out, so I suggest adding a timeout to kill the interval:
(function($) {
var interval = setInterval(pingServer, 60000);
function pingServer() {
$.ajax({ url: location.href });
}
setTimeout(function() {
clearInterval(interval);
}, 1440000);
})(jQuery);
回答3:
I think this will work, as a use has say, this is normal setting you can do in PHP and PHP.ini
If you not can use this try to edit the URL you call to
<script type="text/javascript">
function pingServer() {
$.ajax({ url: "/ping.php" });
}
$(document).ready(function() {
setInterval('pingServer()', 60000);
});
</script>
And in the file ping.php you has.
<?php
session_start();
$_SESSION['last_ping'] = time();
?>
For force PHP to update you server side session cookie.
This can also be a miss config in the setting for OpenCart?
回答4:
for opencart 1.5.x just open /system/library/session.php and add this line
ini_set('session.gc_maxlifetime',5400);//90 minute
来源:https://stackoverflow.com/questions/12386548/opencart-how-do-you-increase-the-admin-session-timeout