From 72475e4b96c584942614f666b65a4c6beb3b4b2c Mon Sep 17 00:00:00 2001 From: spinettaro Date: Fri, 20 Jan 2017 17:29:09 +0100 Subject: [PATCH] fixed session timeout when timeout value is 0 --- sources/MVCFramework.Session.pas | 10 +++++++++- sources/MVCFramework.pas | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sources/MVCFramework.Session.pas b/sources/MVCFramework.Session.pas index af5866ac..f4913a63 100644 --- a/sources/MVCFramework.Session.pas +++ b/sources/MVCFramework.Session.pas @@ -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; diff --git a/sources/MVCFramework.pas b/sources/MVCFramework.pas index 679b88be..4325ff4b 100644 --- a/sources/MVCFramework.pas +++ b/sources/MVCFramework.pas @@ -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;