Einzelnen Beitrag anzeigen

Sergej_Molotov

Registriert seit: 18. Jul 2006
61 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: Delphi 10.3 SOAP - Cookies werden nicht gespeichert

  Alt 14. Feb 2019, 11:48
Delphi-Quellcode:
  TForm1 = class(TForm)
    HTTPRIOLogin: THTTPRIO;
    HTTPRIOPicture: THTTPRIO;
    procedure HTTPRIOLoginHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Client: THTTPClient);
    procedure HTTPRIOPictureHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Client: THTTPClient);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    FLogin: SoapLoginService;
    FPicture: SoapPictureService;
    FCookieManager: TCookieManager; // im Create oder Show auf nil setzen
  public
    { Public-Deklarationen }
  end;

procedure TForm1.HTTPRIOLoginHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Client: THTTPClient);
begin
  if FCookieManager = nil then
    FCookieManager := Client.CookieManager;
end;

procedure TForm1.HTTPRIOPictureHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Client: THTTPClient);
var
  aCookie: TCookie;
begin

  for aCookie in FCookieManager.Cookies do
  begin
    if aCookie.Name = 'JSESSIONIDthen
      Client.CookieManager.AddServerCookie(aCookie, TUri.Create(HTTPRIOPicture.URL));
  end;
end;
Thomas
  Mit Zitat antworten Zitat