Auto logout issue RRS feed

  • Question

  • User1510859543 posted

    We have an asp.net intranet application that automatically logs out certain workstations after x minutes of inactivity (user specified).  We are storing the # minutes in a hidden textbox named txtLogoutMinutes which is set in Page_Load code.  All works great except that if they are typing into the page, it still logs them out because (I think) the page is still idle.  We would like to have any typing reset the timeout period back to the default.  Could this be handled in something like a keypress function, e.g. window.onkeypress or something?  Below is the javascript we are using (p.s. jquery would be ok also).

            //redirect browser after x minutes of inactivity (300,000 milliseconds = 5 minutes) if shared counter PC
            if (document.getElementById('ckIsSharedPC').checked == true) {
                var iminutes = document.getElementById('txtLogoutMinutes').value;
                //set logout default to 5 minutes
                var imseconds = 300000;
                if (iminutes != '') {
                    //set logout default to minutes in BodyShopOption
                    imseconds = parseInt(iminutes * 60 * 1000);
                setTimeout(function () { back2login() }, imseconds);
            function back2login() {
                var sappurl = '../BodyShopLogin.aspx';

    Monday, August 15, 2016 2:21 PM


All replies

  • User-1142886626 posted

    Hi dlchase,

    If you want to determine whether the current user is active. You could use some jQuery events. Such as mousemove, click, mouseup, mousedown, keydown, keypress, keyup, submit, change, mouseenter, scroll, resize, dbclick. And bind all these event, then under the events using  ClearTimeout(), it clears a timer set with the setTimeout() method. Finally, call setTimeout() method again reset the Timer.

    The following example is for your reference.

    <script type="text/javascript">
        $(function () {
        var yourTimer = setTimeout(function () {
        }, imseconds)
        $('*').bind('mousemove click mouseup mousedown keydown keypress keyup submit change mouseenter scroll resize dblclick', function () {
            yourTimer = setTimeout(function () {
            }, imseconds)

    Best Regards,


    Tuesday, August 16, 2016 11:27 AM
  • User-2057865890 posted

    Hi Dlchase,

    As you said they are typing in the page. So may be it is a Textbox or some other control.

    So you can use the Events of that control. You can select the event which is suitable to you.

    You can create variable imseconds as global.

    Then when the event of the control get fired then you can delayed the logout time by setting or modifying the value of imseconds.

    Also you can try to visit the link below in which other users have an issue like you.

    So I think you can get a better idea to solve your issue.

    How to track of page is already idle


    If no activity for 15 minutes, display an alert on web page, and then either continue or logout


    Configure Idle Time-out Settings for an Application Pool (IIS 7)




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 18, 2016 9:54 AM
  • User1510859543 posted

    I modified the "15 minute" link code to fit my situation.

    Friday, August 19, 2016 5:02 PM