|
@@ -57,6 +57,8 @@ Type
|
|
FSessionDir: String;
|
|
FSessionDir: String;
|
|
FTerminated :Boolean;
|
|
FTerminated :Boolean;
|
|
SID : String;
|
|
SID : String;
|
|
|
|
+ private
|
|
|
|
+ procedure FreeIniFile;
|
|
Protected
|
|
Protected
|
|
Procedure CheckSession;
|
|
Procedure CheckSession;
|
|
Function GetSessionID : String; override;
|
|
Function GetSessionID : String; override;
|
|
@@ -145,6 +147,13 @@ begin
|
|
Result:=SID;
|
|
Result:=SID;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TIniWebSession.FreeIniFile;
|
|
|
|
+begin
|
|
|
|
+ If Cached and Assigned(FIniFile) then
|
|
|
|
+ TMemIniFile(FIniFile).UpdateFile;
|
|
|
|
+ FreeAndNil(FIniFile);
|
|
|
|
+end;
|
|
|
|
+
|
|
Procedure TIniWebSession.CheckSession;
|
|
Procedure TIniWebSession.CheckSession;
|
|
|
|
|
|
begin
|
|
begin
|
|
@@ -173,9 +182,9 @@ end;
|
|
|
|
|
|
destructor TIniWebSession.Destroy;
|
|
destructor TIniWebSession.Destroy;
|
|
begin
|
|
begin
|
|
- If Cached and Assigned(FIniFile) then
|
|
|
|
- TMemIniFile(FIniFile).UpdateFile;
|
|
|
|
- FreeAndNil(FIniFile);
|
|
|
|
|
|
+ // In case an exception occured and UpdateResponse is not called,
|
|
|
|
+ // write the updates to disk and free FIniFile
|
|
|
|
+ FreeIniFile;
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -192,8 +201,7 @@ end;
|
|
procedure TIniWebSession.UpdateResponse(AResponse: TResponse);
|
|
procedure TIniWebSession.UpdateResponse(AResponse: TResponse);
|
|
begin
|
|
begin
|
|
// Do nothing. Init has done the job.
|
|
// Do nothing. Init has done the job.
|
|
- If Cached and Assigned(FIniFile) then
|
|
|
|
- TMemIniFile(FIniFile).UpdateFile;
|
|
|
|
|
|
+ FreeIniFile;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TIniWebSession.InitSession(ARequest: TRequest; OnNewSession,OnExpired: TNotifyEvent);
|
|
procedure TIniWebSession.InitSession(ARequest: TRequest; OnNewSession,OnExpired: TNotifyEvent);
|
|
@@ -204,6 +212,14 @@ Var
|
|
S : String;
|
|
S : String;
|
|
begin
|
|
begin
|
|
{$ifdef cgidebug}SendMethodEnter('TIniWebSession.InitSession');{$endif}
|
|
{$ifdef cgidebug}SendMethodEnter('TIniWebSession.InitSession');{$endif}
|
|
|
|
+ // First initialize all session-dependent properties to their default, because
|
|
|
|
+ // in Apache-modules or fcgi programs the session-instance is re-used
|
|
|
|
+ SID := '';
|
|
|
|
+ FSessionStarted := False;
|
|
|
|
+ FTerminated := False;
|
|
|
|
+ // If a exception occured during a prior request FIniFile is still not freed
|
|
|
|
+ if assigned(FIniFile) then FreeIniFile;
|
|
|
|
+
|
|
If (SessionCookie='') then
|
|
If (SessionCookie='') then
|
|
SessionCookie:=SFPWebSession;
|
|
SessionCookie:=SFPWebSession;
|
|
S:=ARequest.CookieFields.Values[SessionCookie];
|
|
S:=ARequest.CookieFields.Values[SessionCookie];
|
|
@@ -324,16 +340,10 @@ end;
|
|
|
|
|
|
procedure TSessionHTTPModule.CheckSession(ARequest : TRequest);
|
|
procedure TSessionHTTPModule.CheckSession(ARequest : TRequest);
|
|
|
|
|
|
-Var
|
|
|
|
- S : TCustomSession;
|
|
|
|
-
|
|
|
|
begin
|
|
begin
|
|
{$ifdef cgidebug}SendMethodEnter('SessionHTTPModule('+Name+').CheckSession');{$endif}
|
|
{$ifdef cgidebug}SendMethodEnter('SessionHTTPModule('+Name+').CheckSession');{$endif}
|
|
If CreateSession and Assigned(FSession) then
|
|
If CreateSession and Assigned(FSession) then
|
|
- begin
|
|
|
|
- S:=FSession;
|
|
|
|
FSession.InitSession(ARequest,FOnNewSession,FOnSessionExpired);
|
|
FSession.InitSession(ARequest,FOnNewSession,FOnSessionExpired);
|
|
- end;
|
|
|
|
{$ifdef cgidebug}SendMethodExit('SessionHTTPModule('+Name+').CheckSession');{$endif}
|
|
{$ifdef cgidebug}SendMethodExit('SessionHTTPModule('+Name+').CheckSession');{$endif}
|
|
end;
|
|
end;
|
|
|
|
|