mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 03:19:17 +02:00
* Allow session file prefix. Make sessiondir readable
git-svn-id: trunk@21770 -
This commit is contained in:
parent
e06927d623
commit
003a7ca217
@ -48,6 +48,7 @@ Type
|
|||||||
Procedure InitSession(ARequest : TRequest; OnNewSession, OnExpired: TNotifyEvent); override;
|
Procedure InitSession(ARequest : TRequest; OnNewSession, OnExpired: TNotifyEvent); override;
|
||||||
Procedure InitResponse(AResponse : TResponse); override;
|
Procedure InitResponse(AResponse : TResponse); override;
|
||||||
Procedure RemoveVariable(VariableName : String); override;
|
Procedure RemoveVariable(VariableName : String); override;
|
||||||
|
Function GetSessionDir : String;
|
||||||
end;
|
end;
|
||||||
TIniWebSessionClass = Class of TIniWebSession;
|
TIniWebSessionClass = Class of TIniWebSession;
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ Type
|
|||||||
// Sweep session direcory and delete expired files.
|
// Sweep session direcory and delete expired files.
|
||||||
procedure DoCleanupSessions; override;
|
procedure DoCleanupSessions; override;
|
||||||
Procedure DoDoneSession(Var ASession : TCustomSession); override;
|
Procedure DoDoneSession(Var ASession : TCustomSession); override;
|
||||||
|
Function SessionFilePrefix : String; virtual;
|
||||||
Public
|
Public
|
||||||
// Directory where sessions are kept.
|
// Directory where sessions are kept.
|
||||||
Property SessionDir : String Read FSessionDir Write SetSessionDir;
|
Property SessionDir : String Read FSessionDir Write SetSessionDir;
|
||||||
@ -212,8 +214,20 @@ begin
|
|||||||
FreeAndNil(ASession);
|
FreeAndNil(ASession);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function TIniSessionFactory.SessionFilePrefix : String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
end;
|
||||||
|
|
||||||
{ TIniWebSession }
|
{ TIniWebSession }
|
||||||
|
|
||||||
|
Function TIniWebSession.GetSessionDir : String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=SessionDir;
|
||||||
|
end;
|
||||||
|
|
||||||
function TIniWebSession.GetSessionID: String;
|
function TIniWebSession.GetSessionID: String;
|
||||||
begin
|
begin
|
||||||
If (SID='') then
|
If (SID='') then
|
||||||
@ -282,8 +296,10 @@ procedure TIniWebSession.InitSession(ARequest: TRequest; OnNewSession,OnExpired:
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
S : String;
|
S : String;
|
||||||
|
SF : TIniSessionFactory;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
SF:=SessionFactory as TIniSessionFactory;
|
||||||
{$ifdef cgidebug}SendMethodEnter('TIniWebSession.InitSession');{$endif}
|
{$ifdef cgidebug}SendMethodEnter('TIniWebSession.InitSession');{$endif}
|
||||||
// First initialize all session-dependent properties to their default, because
|
// First initialize all session-dependent properties to their default, because
|
||||||
// in Apache-modules or fcgi programs the session-instance is re-used
|
// in Apache-modules or fcgi programs the session-instance is re-used
|
||||||
@ -299,13 +315,13 @@ begin
|
|||||||
If (S<>'') then
|
If (S<>'') then
|
||||||
begin
|
begin
|
||||||
{$ifdef cgidebug}SendDebug('Reading ini file:'+S);{$endif}
|
{$ifdef cgidebug}SendDebug('Reading ini file:'+S);{$endif}
|
||||||
FIniFile:=TMemIniFile.Create(IncludeTrailingPathDelimiter(SessionDir)+S);
|
FIniFile:=TMemIniFile.Create(IncludeTrailingPathDelimiter(SessionDir)+SF.SessionFilePrefix+S);
|
||||||
if (SessionFactory as TIniSessionFactory).SessionExpired(FIniFile) then
|
if SF.SessionExpired(FIniFile) then
|
||||||
begin
|
begin
|
||||||
// Expire session.
|
// Expire session.
|
||||||
If Assigned(OnExpired) then
|
If Assigned(OnExpired) then
|
||||||
OnExpired(Self);
|
OnExpired(Self);
|
||||||
(SessionFactory as TIniSessionFactory).DeleteSessionFile(FIniFIle.FileName);
|
SF.DeleteSessionFile(FIniFIle.FileName);
|
||||||
FreeAndNil(FInifile);
|
FreeAndNil(FInifile);
|
||||||
S:='';
|
S:='';
|
||||||
end
|
end
|
||||||
@ -317,7 +333,7 @@ begin
|
|||||||
If Assigned(OnNewSession) then
|
If Assigned(OnNewSession) then
|
||||||
OnNewSession(Self);
|
OnNewSession(Self);
|
||||||
GetSessionID;
|
GetSessionID;
|
||||||
S:=IncludeTrailingPathDelimiter(SessionDir)+SessionID;
|
S:=IncludeTrailingPathDelimiter(SessionDir)+SF.SessionFilePrefix+SessionID;
|
||||||
{$ifdef cgidebug}SendDebug('Creating new Ini file : '+S);{$endif}
|
{$ifdef cgidebug}SendDebug('Creating new Ini file : '+S);{$endif}
|
||||||
FIniFile:=TMemIniFile.Create(S);
|
FIniFile:=TMemIniFile.Create(S);
|
||||||
FIniFile.WriteDateTime(SSession,KeyStart,Now);
|
FIniFile.WriteDateTime(SSession,KeyStart,Now);
|
||||||
|
Loading…
Reference in New Issue
Block a user