Got this code off a website i didnt make it myself just added the if logged.
Add it to catalog/view/theme/default/template/common/header.twig just before </header>
Remember to set the timer in (var IDLE_TIMEOUT = 3600;) // <---- set your timer in seconds 3600 is 10 mins, set it lower to test like 30 seconds.
Code: Select all
{% if logged %}
<script type="text/javascript">
var IDLE_TIMEOUT = 3600; //seconds
var _idleSecondsCounter = 0;
document.onclick = function () {
_idleSecondsCounter = 0;
};
document.onmousemove = function () {
_idleSecondsCounter = 0;
};
document.onkeypress = function () {
_idleSecondsCounter = 0;
};
window.setInterval(CheckIdleTime, 1000);
function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
document.location.reload();
}
}
</script>
{% endif %}