简体   繁体   中英

OpenCart - How do you increase the Admin session timeout?

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

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() )

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);

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?

对于opencart 1.5.x,只需打开/system/library/session.php并添加此行

ini_set('session.gc_maxlifetime',5400);//90 minute

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM