Hello
Is is possible to get a list of active sessions?
The reason for my question is that i found that there are orphaned files related to expired sessions that was not deleted, and i want to create a periodic clean-up process to delete files not related to active sessions.
PS: My files are stored in application directory with the session ID name.
Mohamed
(04-15-2018, 11:04 PM)mhammady Wrote: [ -> ]Hello
Is is possible to get a list of active sessions?
The reason for my question is that i found that there are orphaned files related to expired sessions that was not deleted, and i want to create a periodic clean-up process to delete files not related to active sessions.
PS: My files are stored in application directory with the session ID name.
Mohamed
You can try something like the following to get a list of sessions. I found this code, or something similar, online some time back. Some of the locks may be redundant.
Code:
function ListOfSessionHandles:string;
var
i: integer;
LSessions: TList;
LSession:TIWApplication;
begin
result:='';
LSessions:=GSessions.LockList;
try
for i := 0 to (LSessions.Count-1) do
begin
LSession:=LSessions[i];
LSession.Lock;
try
result:=result+'|'+inttostr(TIWUserSession(LSession.Data).SessionWorkstationHandle);
finally
LSession.Unlock;
LSession:=nil;
end;
end;
finally
GSessions.UnLockList(LSessions);
end;
That said, it only gives you a list of active sessions. You'd have to keep up with all sessions in order to find your targets.
Another approach is to "clean up" entirely on some basis. You can drop an entire subdirectory on server shutdown (and add it on startup if necessary).
You might also consider killing the subdirectory if you routinely get down to zero sessions.
Dan
Thank you Dan. I shall give it a try...
Mohamed