Jump to content

Log SessionID and IP


erich.wanker
 Share

Recommended Posts

Hello,

 

i try to log Session-ID and IP - but doesn´t work ?

 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
UniServerModule.SessionManager.Sessions.GetSession(aktuell_session,aktuell_ip);
aktuell_session:='[SessionID:'+aktuell_session+'] ';
aktuell_ip:='[DeviceIP:'+aktuell_ip+'] ';
UniServerModule.Logger.AddLog(aktuell_session+aktuell_ip+' -> starts');

any Ideas what´s wrong ?

 

ThanX

 

 

 

Link to comment
Share on other sites

Try modify this code


var i : Integer;

    ASessionList: TList;
    ASession : TUniGUISession;
    s: string;
    iActiveSession: Integer;
begin
    lstSessions.Clear;
    ASessionList:=UniServerModule.SessionManager.Sessions.SessionList.LockList;
    try
       for i := 0 to ASessionList.Count-1 do begin
          ASession := TUniGUISession(ASessionList);
          if not ASession.IsTerminated then begin
               s:=TUniGUISession(ASessionList).UniApplication.UniSession.SessionID+' ('+
                  TUniGUISession(ASessionList).UniApplication.RemoteAddress+
                  ', browser '+TUniGUISession(ASessionList).UniApplication.ClientInfoRec.BrowserType+
                  TUniGUISession(ASessionList).UniApplication.ClientInfoRec.BrowserVersion.ToString+')' ;
               if Pos(UniSession.SessionID,s)<>0 then begin
                  s:='<b>'+s+' - Current session!</b>';
                  iActiveSession:=i;
               end;
               s:='<img src="images/domain_template.png" align="left"/> <p style="font-size:11px"/>'+s;
               lstSessions.Items.Add(s);
          end;
       end;
       lstSessions.ItemIndex:=iActiveSession;
       btnSessionClose.Enabled:=False;
       if lstSessions.Items.Count=1 then btnCloseAllSessions.Enabled:=False
       else btnCloseAllSessions.Enabled:=True;
    finally
       UniServerModule.SessionManager.Sessions.SessionList.UnlockList;
    end;

 

This code from my project, untreated. So my apologies

 

  • Upvote 1
Link to comment
Share on other sites

i found a solution..

 

aktuell_session:=UniApplication.UniSession.SessionID;
aktuell_ip:=UniApplication.RemoteAddress;
aktuell_session:='[sessionID:'+aktuell_session+'] ';
aktuell_ip:='[DeviceIP:'+aktuell_ip+'] ';
if mainform.logger=true then UniServerModule.Logger.AddLog(mainform.aktuell_username,mainform.aktuell_session+mainform.aktuell_ip);
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...