Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Problem mit IdHTTPserver Session (https://www.delphipraxis.net/211943-problem-mit-idhttpserver-session.html)

Hobbycoder 24. Nov 2022 16:40

Problem mit IdHTTPserver Session
 
Liste der Anhänge anzeigen (Anzahl: 2)
Hi Leute,

ich taste mich mal wieder an das Thema IdHTTPServer / Session ran. Bisher habe ich das immer irgendwie anders gelöst, aber nun möchte ich das mal mit der integrierten Session probieren.
Session wird auch erstellt, aber wenn ich dort Content ablegen will habe ich ein Problem.

Delphi-Quellcode:
    FHttpServer.OnCommandGet:=OnCommand;
    FHttpServer.Bindings.Clear;
    FHttpServer.DefaultPort:=FPort;
    FHttpServer.SessionState:=True;
    FHttpServer.AutoStartSession:=True;
    FHttpServer.SessionTimeOut:=5000;
    FHttpServer.Active:=True;
Und im OnCommand
Delphi-Quellcode:
  try
    user:=GetField(ARequestInfo, 'Username');
    pass:=GetField(ARequestInfo, 'Password');
    if (user<>'') and (pass<>'') then
    begin
      u:=FUserList.Login(user, pass);
      if u<>nil then
      begin
        ARequestInfo.Session.Content.AddPair('Username', u.Username);
        ARequestInfo.Session.Content.AddPair('Guid', u.Guid);
...
Im ersten ARequestInfo.Session.Content.AddPair existiert "Content" noch.
Beim zweiten ist Content dann nil. (siehe Anhang).

Wie macht man's richtig?

Gibt's irgendwo mal ein richtig gutes Tutorial für das alles?

Olli73 25. Nov 2022 11:29

AW: Problem mit IdHTTPserver Session
 
Probiers mal mit RequestInfo.Session.Lock / .unlock

Hobbycoder 25. Nov 2022 14:00

AW: Problem mit IdHTTPserver Session
 
Zitat:

Zitat von Olli73 (Beitrag 1515363)
Probiers mal mit RequestInfo.Session.Lock / .unlock

Delphi-Quellcode:
        ARequestInfo.Session.Lock;
        ARequestInfo.Session.Content.AddPair('Username', u.Username);
        ARequestInfo.Session.Content.AddPair('Guid', u.Guid);
        ARequestInfo.Session.Unlock;
Funktioniert, jedoch nur zur Runtime.
Beim Debuggen ist Content im zweiten AddPair = nil. Ich glaube aber so komme ich weiter.

Danke schön :-)

Hobbycoder 25. Nov 2022 14:45

AW: Problem mit IdHTTPserver Session
 
Zitat:

Zitat von Olli73 (Beitrag 1515363)
Probiers mal mit RequestInfo.Session.Lock / .unlock

Du kannst mir nicht zufällig sagen, wie man eine Session manuell löscht?

Olli73 25. Nov 2022 15:35

AW: Problem mit IdHTTPserver Session
 
Probier Mal Server.EndSession(RequestInfo.Session.SessionID)

Hobbycoder 25. Nov 2022 17:29

AW: Problem mit IdHTTPserver Session
 
Zitat:

Zitat von Olli73 (Beitrag 1515396)
Probier Mal Server.EndSession(RequestInfo.Session.SessionID)

Super, Danke


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:22 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz