Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enforce session timeout without user interaction
#2
Here's how I do it:

Add a TDateTime lastAccess variable to UserSession, set to Now() on creation.

Add a TIWTimer to form, set Interval to 60000, set OnAsyncTimer event to something like
  //logout after 5 min of no action
  if(SecondsBetween(Now(),lastAccess) > 298) {
    UserSession()->LogMsg("timeout");
    WebApplication->TerminateAndRedirect("/endDFWPE.html");
  }

Add 'lastAccess = Now();' to all events triggered by useage (button clicks, etc).

Set session timeout to something greater than OnAsyncTimer value test.



The app will now redirect to a static page after 5 min of no usage automatically.
I've tried putting a timer in a usersession but it did not trigger so I think a timer on each form might be the only way.  If you have hundreds of forms maybe use Visual Form Inheritance so that each form derived will have your timer and logic automatically.
Reply


Messages In This Thread
RE: Enforce session timeout without user interaction - by MJS@mjs.us - 10-11-2018, 02:12 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)