Browse Source

* Include trailing path delimiter. Check if session exists; Added some debug statements (in CGIDebug conditional)

git-svn-id: trunk@15566 -
michael 15 years ago
parent
commit
0ee895f141
1 changed files with 14 additions and 5 deletions
  1. 14 5
      packages/fcl-web/src/base/websession.pp

+ 14 - 5
packages/fcl-web/src/base/websession.pp

@@ -125,7 +125,10 @@ begin
 {$ifdef cgidebug}SendMethodEnter('GetDefaultSession');{$endif}
 {$ifdef cgidebug}SendMethodEnter('GetDefaultSession');{$endif}
   Result:=Nil;
   Result:=Nil;
   If (GlobalSessionDir='') then
   If (GlobalSessionDir='') then
-    GlobalSessionDir:=IncludeTrailingPathDelimiter(GetTempDir(True));
+    GlobalSessionDir:=IncludeTrailingPathDelimiter(GetTempDir(True))
+  else
+    GlobalSessionDir:=IncludeTrailingPathDelimiter(GlobalSessionDir);
+{$ifdef cgidebug}SendDebug('GetDefaultSession, session dir: '+GlobalSessionDir);{$endif}
   If Assigned(OnGetDefaultSession) then
   If Assigned(OnGetDefaultSession) then
     OnGetDefaultSession(Result);
     OnGetDefaultSession(Result);
   if (Result=Nil) then
   if (Result=Nil) then
@@ -257,8 +260,9 @@ begin
     If Assigned(OnNewSession) then
     If Assigned(OnNewSession) then
       OnNewSession(Self);
       OnNewSession(Self);
     GetSessionID;
     GetSessionID;
-{$ifdef cgidebug}SendDebug('Creating new Ini file : '+SessionID);{$endif}
-    FIniFile:=TMemIniFile.Create(IncludeTrailingPathDelimiter(SessionDir)+SessionID);
+    S:=IncludeTrailingPathDelimiter(SessionDir)+SessionID;
+{$ifdef cgidebug}SendDebug('Creating new Ini file : '+S);{$endif}
+    FIniFile:=TMemIniFile.Create(S);
     FIniFile.WriteDateTime(SSession,KeyStart,Now);
     FIniFile.WriteDateTime(SSession,KeyStart,Now);
     FIniFile.WriteInteger(SSession,KeyTimeOut,Self.TimeOutMinutes);
     FIniFile.WriteInteger(SSession,KeyTimeOut,Self.TimeOutMinutes);
     FSessionStarted:=True;
     FSessionStarted:=True;
@@ -342,8 +346,13 @@ procedure TSessionHTTPModule.CheckSession(ARequest : TRequest);
 
 
 begin
 begin
 {$ifdef cgidebug}SendMethodEnter('SessionHTTPModule('+Name+').CheckSession');{$endif}
 {$ifdef cgidebug}SendMethodEnter('SessionHTTPModule('+Name+').CheckSession');{$endif}
-  If CreateSession and Assigned(Session) then
-    Session.InitSession(ARequest,FOnNewSession,FOnSessionExpired);
+  If CreateSession then
+    begin
+    If (FSession=Nil) then
+      FSession:=GetDefaultSession;
+    if Assigned(Session) then
+      Session.InitSession(ARequest,FOnNewSession,FOnSessionExpired);
+    end;
 {$ifdef cgidebug}SendMethodExit('SessionHTTPModule('+Name+').CheckSession');{$endif}
 {$ifdef cgidebug}SendMethodExit('SessionHTTPModule('+Name+').CheckSession');{$endif}
 end;
 end;