Atozed Forums
servercontroller -> Onclose session call to url - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: servercontroller -> Onclose session call to url (/thread-2497.html)



servercontroller -> Onclose session call to url - joelcc - 08-30-2021

In the IWServerControllerBaseCloseSession I need to be able to call a url to close a session on an identity server.  (I do not need to redirect the user.   I only need to call the url)

Has anyone already done this?

Thanks.


RE: servercontroller -> Onclose session call to url - Alexandre Machado - 08-31-2021

IntraWeb has utility classes to perform this task:

Code:
implementation

{$R *.dfm}

uses
  IWInit, IWGlobal, IW.Common.Threads, IW.HTTP.IndyClient;

{ TIWServerController }

procedure TIWServerController.IWServerControllerBaseCloseSession(
  aSession: TIWApplication);
begin
  if Assigned(aSession) then
  begin
    TIWThreadBase.ExecInThread(
      procedure (AThread: TObject)
      var
        IndyClient: TIWHTTPClient;
      begin
        IndyClient := TIWHTTPClient.Create;
        try
          IndyClient.Get('http(s)://yourserver.com/theurl');
          // or
          // IndyClient.Post('http(s)://yoursever.com/theurl', 'Param1=Value1');  // there are 2 other overloads of this
        finally
          IndyClient.Free;
        end;
      end,
      'Thread_' + aSession.AppID);  // <- the name of the thread is just nice to have
  end;
end;

In this code I use the TIWHttpClient to send a GET or POST request to some arbitrary URL from a Thread (so it won't block the termination of the session - have in mind that connection to a different server, especially using HTTPS, can take a long time).

HTTPS connections also require OpenSSL DLLs available in the same directory where your application is.


RE: servercontroller -> Onclose session call to url - joelcc - 09-03-2021

Thanks. That looks like it is exactly what we needed.