Implement auto log-out + warning in asp.net + jquery?
<p>Many sites ( Bank webSite for example)  - implement log-out  + 1 minute warning before session is about to expire.( 20 minutes)</p>

<p>(<em>this topic is not discussed much - the only question ive seen is with using asp.net membership  - which I don't use</em>)</p>

<p>each user will have a <code>session["lastActionTime"]</code></p>

<p>this session will be update to current <em>Time</em> when : </p>

<ul>
<li>Page is loaded</li>
<li>Ajax request has executed ( due to user action)</li>
</ul>

<p>Now  - when a page loads , I set the session value. (lets say 19:00)</p>

<p>Also , for every ajax request (my site doesnt create postbacks - only ajax jquery) - I use an ASHX handler with <code>IRequiresSessionState</code> which updates the session to current Time.</p>

<p>I use something like this : </p>

<pre><code>jQuery(document).ajaxStart(function(){
    gotoHandlerAndUpdateSessionTime();
})
</code></pre>

<p>Now  -the part for 1 minute before warning message ( " <em>your session is about to expire</em> ") : </p>

<p>Every ajax return event or <code>page load</code> event - I activate in <em>javascript</em> : <code>setInterval</code> with <code>[sessionTime-1]</code> minutes ( 20-1=19). ( and of course - cancelling all prev setIntervals... )</p>

<p>now when the event (setInterval) occurs  - it is 1 minute before expiration time : (19 min)</p>

<p>I display a warning div  , and the user can choose <kbd>exit</kbd> or <kbd>stay</kbd> .</p>

<p>question : </p>

<p>1) what if the user didnt press nothing on the warning div , How (<em>after 1 minute from displaying the div</em>) will I log him out  ? Should I open a setTimeout of 1 minute when displaying the div  and then (if nothing pressed) to log him out ?</p>

<p>2) is it the right way of doing it ?</p>

<p>3) Shouldn't there be cookies in this whole weird story ? :-)</p>

<p><em>(please - no membership - or Forms authentication).
I'm tagging this question also as PHP since I know it is relevant to php programmers as well and I would like to hear from their knowledge.</em></p>
