Asp.net: Implementing Auto-Logout functionality

后端 未结 4 1035
深忆病人
深忆病人 2020-12-09 13:32

I have to implement auto-logout functionality in one of my projects and i just cant figure out where to start looking for ideas but SO.

What i need

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 14:09

    This has been achieved by the following way:

    1) Save the time-stamp of every request( server and ajax excluding the session check ajax request) to the server into a session var.

    2) Poll the server via a JS function using ajax at frequent intervals and check if the time diff between the session time-stamp and the ajax request time is greater than the session timeout val then log-off the current user and return a bool for that ajax request.

    3) Redirect the current page to the login page if the bool returned is true.

提交回复
热议问题