fixed session timeout when timeout value is 0

This commit is contained in:
spinettaro 2017-01-20 17:29:09 +01:00
parent 808e3902d1
commit 72475e4b96
2 changed files with 14 additions and 2 deletions

View File

@ -29,6 +29,10 @@ interface
uses System.SysUtils,
System.Generics.Collections;
const
DEFAULT_SESSION_INACTIVITY = 60; // in minutes
type
TWebSession = class abstract
strict protected
@ -136,7 +140,11 @@ end;
function TWebSession.IsExpired: Boolean;
begin
Result := MinutesBetween(now, LastAccess) > FTimeout;
// spinettaro sessiontimeout -- if a session cookie has been choosed the inactivity time is 60 minutes
if FTimeout = 0 then
Result := MinutesBetween(now, LastAccess) > DEFAULT_SESSION_INACTIVITY
else
Result := MinutesBetween(now, LastAccess) > FTimeout;
end;
procedure TWebSession.MarkAsUsed;

View File

@ -1268,7 +1268,11 @@ begin
IsExpired := true;
if List.TryGetValue(ASessionID, Result) then
begin
IsExpired := MinutesBetween(Now, Result.LastAccess) > ASessionTimeout;
// spinettaro sessiontimeout -- if a session cookie has been choosed the inactivity time is 60 minutes
if ASessionTimeout = 0 then
IsExpired := MinutesBetween(Now, Result.LastAccess) > DEFAULT_SESSION_INACTIVITY
else
IsExpired := MinutesBetween(Now, Result.LastAccess) > ASessionTimeout;
// StrToInt(Config.Value['sessiontimeout']);
end;