|Subject:||Re: Problem with cookie based sessions|
|Posted by:||Remy Lebeau \(Indy Team\) (email@example.com)|
|Date:||Thu, 17 Sep 2009|
"Christian Kaufmann" <christian.kaufma…@gmx.net> wrote in message
> But I cannot read the cookies in PHP
Why not? You need to be more specific. Did you validate that the server is
sending the cookies to your PHP script to begin with? Did you verify that
PHP is not rejecting them?
> So I'm looking for another way. One idea is, that I send the PHP
> session id as get variable (or cookie) to my delphi application.
That is an option. JSP does that, for instance.
> But how can I configure my TIdHttpServer component to use that
> cookie / get var as session identifier and not create a new (own) one?
TIdHTTPServer only supports cookie-based sessions natively. For what you
are asking, you would have to set the server's AutoStartSession property to
False, and then assign the TIdHTTPRequestInfo.Session and
TIdHTTPResponseInfo.Session properties manually inside the OnCommand...
events as needed, ie:
TIdHTTPRequestInfoAccess = class(TIdHTTPRequestInfo)
TIdHTTPResponseInfoAccess = class(TIdHTTPResponseInfo)
procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext; ARequestInfo:
TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
LSessionID := ...;
LSession := nil;
if LSessionID <> '' then
LSession := IdHTTPServer1.SessionList.GetSession(LSessionID,
if LSession = nil then
... report an error to the client ...
TIdHTTPRequestInfoAccess(ARequestInfo).FSession := LSession;
TIdHTTPResponseInfoAccess(AResponseInfo).FSession := LSession;
IdHTTPServer1.CreateSession(AContext, AResponseInfo, ARequestInfo);
Remy Lebeau (Indy Team)
Problem with cookie based sessions posted by Christian Kaufmann on Thu, 17 Sep 2009