Hey I found this
link-[Implementing Auto-Logout functionality][
^] which might be useful for you.
enegadeMind gives perfect answer
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.