ViaThinkSoft CodeLib
Dieser Artikel befindet sich in der Kategorie:
CodeLib → Programmierhilfen → Delphi
procedure TForm14.IdHTTPServer1Command(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
ctx: TMyContext;
begin
ctx.Context := AContext;
ctx.RequestInfo := ARequestInfo;
ctx.ResponseInfo := AResponseInfo;
ctx.Server := IdHTTPServer1;
...
end;
{ TMyContext }
type
TMyContext = record
Context: TIdContext;
RequestInfo: TIdHTTPRequestInfo;
ResponseInfo: TIdHTTPResponseInfo;
Server: TIdHTTPServer;
function GetSesVal(name: string): string;
function SetSesVal(name, val: string): string;
procedure SesLogout;
end;
function TMyContext.GetSesVal(name: string): string;
begin
if assigned(RequestInfo.Session) or
(Server.CreateSession(Context, ResponseInfo, RequestInfo) <> nil) then
begin
RequestInfo.Session.Lock;
try
result := RequestInfo.Session.Content.Values[name];
finally
RequestInfo.Session.Unlock;
end;
end;
end;
procedure TMyContext.SesLogout;
begin
if Assigned(RequestInfo.Session) then
begin
Server.EndSession(RequestInfo.Session.SessionID);
end;
end;
function TMyContext.SetSesVal(name, val: string): string;
begin
if assigned(RequestInfo.Session) or
(Server.CreateSession(Context, ResponseInfo, RequestInfo) <> nil) then
begin
RequestInfo.Session.Lock;
try
RequestInfo.Session.Content.Values[name] := val;
finally
RequestInfo.Session.Unlock;
end;
end;
end;
Daniel Marschall
ViaThinkSoft Mitbegründer
ViaThinkSoft Mitbegründer