10-11-2018, 02:12 PM
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.
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.

