locked
Tracking User idle time in ASP.net application RRS feed

  • Question

  • User1052050198 posted

    Hi,

    I know there are plenty of plugins and simple Java script code is available to check if there is no user activity on a loaded page at browser and time out automatically.

    Below one is a very cool example;

    https://forums.asp.net/t/1899214.aspx?If+no+activity+for+15+minutes+display+an+alert+on+web+page+and+then+either+continue+or+logout

    My question is, suppose in an application i have added the code to track user idle time in multiple pages and time out limit is 10 min. And i have opened the pages in multiple tabs in a browser, say one page i have opened on 2:00 pm and i kept that page in one tab, again i open another page in next tab and keep doing some activities on it. Whether after 10 min, the first page that i have opened on 2 pm will automatically goes time out?

    Monday, February 18, 2019 11:19 AM

All replies

  • User475983607 posted

    My question is, suppose in an application i have added the code to track user idle time in multiple pages and time out limit is 10 min. And i have opened the pages in multiple tabs in a browser, say one page i have opened on 2:00 pm and i kept that page in one tab, again i open another page in next tab and keep doing some activities on it. Whether after 10 min, the first page that i have opened on 2 pm will automatically goes time out?

    The linked post has hardcoded timeout values.  The last tab is the most accurate if multiple tabs are opened.  You can always test the code yourself. 

    I generally pass a cookie that has the expiration and use JavaScript to read the cookie.

    Monday, February 18, 2019 11:46 AM
  • User1052050198 posted

    Thanks for the reply.

    In my code, I tried to reproduce the scenario that i have mentioned in my question. I open first page and kept it in one tab. And opened another second page in next tab.. after 10 min first page got time out. I don't want this to happen... Any way to override this? 

    In other words, if i open multiple pages of same application in different tabs and only working on any one of the page, as long as i do something on that page, timer on the rest of the pages also get reset.

    Monday, February 18, 2019 12:21 PM
  • User475983607 posted

    AnuAriv

    In my code, I tried to reproduce the scenario that i have mentioned in my question. I open first page and kept it in one tab. And opened another second page in next tab.. after 10 min first page got time out. I don't want this to happen... Any way to override this? 

    In other words, if i open multiple pages of same application in different tabs and only working on any one of the page, as long as i do something on that page, timer on the rest of the pages also get reset.

    As recommended above, store the expiration DateTime  in a cookie generated dynamically on the server rather than hard coded the timeout in JavaScript.   Cookies are related to the browser instance not the browser tab.  Therefore, each new tab will generate an updated cookie.  Basically all tabs are looking at the same cookie.

    Simply read the cookie at some frequency to determine the time left. 

    Monday, February 18, 2019 12:43 PM
  • User1052050198 posted

    Thank you... I hope this will work perfect for me... Thanks for your time :)

    Tuesday, February 19, 2019 8:22 AM