Reputation: 83
How can create session used with in idhttpserver ?
I tryed alot of ways to do but I can't able to reach session object in ARequestInfo.Session or AResponseInfo.Session these are both of them always nil. please help
procedure TFolsecPermissionManager.IdHTTPServerCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
Command: TCommand;
Session: TIdHTTPSession;
begin
Session := IdHTTPServer.CreateSession(AContext, AResponseInfo, ARequestInfo);
IdHTTPServer.SessionList.Add(Session);
Command:= TCommand.Create;
Command.Start(AContext, ARequestInfo, AResponseInfo);
end;
Upvotes: 1
Views: 1090
Reputation: 595837
Make sure that TIdHTTPServer.SessionState
is set to True
. Optionally, you can also set TIdHTTPServer.AutoStartSession
to True
as well. They are both False
by default.
If both are True
, you do not need to call CreateSession()
manually, as it called automatically for every incoming request that does not carry a cookie for an existing session.
If SessionState=True
and AutoStartSession=False
, you do need to call CreateSession()
manually when desired.
However, no matter what, do not call SessionList.Add()
manually, as CreateSession()
calls that internally for you. You don't want the SessionList
holding multiple references to the same TIdHTTPSession
object.
Upvotes: 1