Note that there are some explanatory texts on larger screens.

plurals
  1. POUser Session Times out if multiple pages are open and one is left inactive using timer in JS/JQuery
    primarykey
    data
    text
    <p>I have a user activity on my page. When user is inactive (<strong>didnt move mouse</strong>) for 30 minutes it prompts user warning that session will expire soon. If user does not click on <strong>OK</strong> button and stay inactive will be automatically logged out (<strong>session destroy</strong>).</p> <p>Now this is being checked in every 25 minutes and everything works fine until user opens multiple tabs of same page. If multiple tabs are opened and user is working on one tab but left the other tab open for 25 minutes it times out.</p> <p>How do i prevent it from timing out session when multiple tabs are open and user is active in at least one of the tabs meaning user is moving the mouse in at least one of the tabs of the page.</p> <p>The js code that detects mouse move is below:</p> <pre><code>timer = 0; function cIncrement() { if (timer == 25) { //25 minutes passed warn user that in 5 minutes it will expire //here is the code that prompts user with dialog if (OK clicked on dialog) { timer = 0; } else { //execute logout script. } } if (timer == 30) { //30 minutes passed log user out //script to log user out } } $(function() { var interval = setInterval("cIncrement()", 60000); //increment every minute //reset timer on mouse move $(document).mousemove(function(e) { timer = 0; }); }); </code></pre> <p><strong>NOTE</strong>: the above code works fine when 1 tab is open.</p> <p>how would i change this so that if 2 or more tabs are open and user is active in any of them should reset <strong>timer</strong> to <strong>0</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload