locked
timeout user after 15 minutes of inactivity RRS feed

  • Question

  • User-1109837135 posted

    Hello, i need to logout the user after 15 minutes of inactivity. i set the param in webconfig to 15 mints and also the JS code will check 15 minutes timer and pop up a window for login again. But the issue is that the pop up appears after 15 minutes of logging in and not after 15 minutes of inactivity.

    any idea why this might happen. below is my code.

    <script type="text/javascript">

    function sessionHasExpired() {
    if (confirm("Your session has expired. You will be redirected login page."))
    {
    window.location ="Login.aspx";}
    }
    var sessionTimeInMilliseconds = 900000;
    setTimeout(sessionHasExpired, sessionTimeInMilliseconds);

    thanks

    Monday, September 10, 2012 8:16 AM

Answers

  • User-964720240 posted

    hi may be following code will help you 

    <authentication mode="Forms">
    <forms  loginUrl="~/login.aspx" name="XESS" protection="None" timeout="120" />

    </authentication>

    in timeout tag you can define your time .

    thank you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 11, 2012 6:44 AM

All replies

  • User1428339021 posted

    change your logic. Try something like this:

    var sessionTimeInMilliseconds = CurrentDateTime - LastActivityDateTime;

    if(sessionTimeInMilliseconds > 900000){

    // your logic here.

    }


    You will have to maintain the LastActivityDateTime on user action.

    Monday, September 10, 2012 8:22 AM
  • User-1109837135 posted

    hello. thanks for your response.

    can you please tell me how and where to maintain LastActivityDateTime ? Where is user action?

     

     

    Monday, September 10, 2012 8:47 AM
  • User1771049139 posted

    You can use following jQuery :

    $(window).bind( 'mousemove mouseclick keydown mousewheel ...more listeners...', idle );
    function idle( e )
    {
     if ( window.idleTimeout )
     {
     clearTimeout( window.idleTimeout );
     }
     window.idleTimeout = setTimeout( userIdle, 900000 );
    }
    function userIdle()
    {
     //either do stuff here or trigger the "idle" event
     $(window).trigger('idle');
    }
    Monday, September 10, 2012 8:49 AM
  • User146802239 posted

    for this u can write code in Globle.ascx file in Session_end Event for rediret on page and second you can write responce on ASPX and take a counter after counter is 15 then you redirect your page on login.aspx and also write Session.abondone() on page load event.

    Tuesday, September 11, 2012 4:45 AM
  • User1428339021 posted

    Whenever user clicks on some button or do a redirection keep the datetime in a hidden field. That ways you can maintain the last activity datetime.

    Tuesday, September 11, 2012 5:04 AM
  • User-964720240 posted

    hi may be following code will help you 

    <authentication mode="Forms">
    <forms  loginUrl="~/login.aspx" name="XESS" protection="None" timeout="120" />

    </authentication>

    in timeout tag you can define your time .

    thank you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 11, 2012 6:44 AM