Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I set different Timeout for different Users?
#9
(03-09-2023, 01:01 PM)jeroen.rottink Wrote: This code redirects the user to SessionTimeout.html when the session timeout occurs.
Be sure to register the mimetype .html as static because it is served without session validation.

Code:
procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
begin
  // register my own exception handler
  IWExceptionRenderer.SetExceptionRendererClass(TIWExceptionRendererEx);
  // register mimetype .html without session validation
  TIWMimeTypes.RegisterType('.html', 'text/html', True);
end;

{ TIWExceptionRendererEx }

class function TIWExceptionRendererEx.RenderHTML(AException: Exception; ARequest: THttpRequest): string;
var Addr: string;
begin
  // the goal here is to respond to a session timeout error with a HTML which
  // will restart a new session
  if AException is EExpiredSession then begin
    Addr := #39 + '/SessionTimeout.html' + #39; // wwwroot/SessionTimeout.html
    Result := '<!DOCTYPE html>' +
              '<html>' +
              '<head>' +
              '<script type="text/javascript">' +
              'setTimeout("window.location=' + Addr + '", 1);' +
              '</script>' +
              '</head>' +
              '<body>' +
              '</body>' +
              '</html>';
  end
  else
    Result := inherited;
end;

Hi,

I tried your code. First in SA
I got 404 - Not found
http://127.0.0.1:8888/SessionTimeout.html

sorry I misspelled. It works
Reply


Messages In This Thread
RE: How do I set different Timeout for different Users? - by Mikael Nilsson - 03-09-2023, 03:18 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)