Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is typically an unrecoverable error which is usually best to be displayed as a standalone error page. Configure the webapplication to display a customized <code>4nn/5nn</code> error page and setup jQuery as follows:</p> <pre><code>$(document).ready(function() { $.ajaxSetup({ error: handleXhrError }); }); function handleXhrError(xhr) { document.open(); document.write(xhr.responseText); document.close(); } </code></pre> <p>This way the server-side <code>4nn/5nn</code> error page will be displayed as if it's been caused by a synchronous request. I've posted a <a href="https://stackoverflow.com/questions/1738785/handling-of-server-side-http-4nn-5nn-errors-in-jquerys-ajax-requests">simliar topic</a> about the subject before.</p> <p>Another way is to postpone the session timeout ajaxically. Use <a href="http://www.w3schools.com/jsref/met_win_setinterval.asp" rel="nofollow noreferrer"><code>setInterval()</code></a> to fire a poll request to the server (which in turn basically grabs the session from the request) every time-of-session-expiration-minus-ten-seconds or so.</p> <pre><code>setInterval(function() { $.get('poll'); }, intervalInMillis); </code></pre> <p>But the caveat is that the session will survive as long as the client has its browser window open, which may at times take <em>too</em> long. You can if necessary combine this with sort of <em>activity checker</em> so that the chance that the session get expired will be minimized. You still need to combine this with a decent <code>4nn/5nn</code> error handler. </p> <pre><code>$(document).ready(function() { $.active = false; $('body').bind('click keypress', function() { $.active = true; }); checkActivity(1800000, 60000, 0); // timeout = 30 minutes, interval = 1 minute. }); function checkActivity(timeout, interval, elapsed) { if ($.active) { elapsed = 0; $.active = false; $.get('poll'); // Let server code basically do a "get session from request". } if (elapsed &lt; timeout) { elapsed += interval; setTimeout(function() { checkActivity(timeout, interval, elapsed); }, interval); } else { alert($.messages.timeout); // "You will be logged out" blah blah. window.location = 'http://example.com/logout'; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload