Jump to content

Session manager


soledue

Recommended Posts

would be nice if every session there is a variable such as tag where I can write in what form is so I can prevent access by other users

 

if you put this variable in the unit servermodule

this is possible, and their sessions should update this variable.

 

now I think I get a session variable by another is not possible.

but Professor Farshad certainly has the final word.

Link to comment
Share on other sites

I'll explain, at every session I have a variable such as UserName I see that variable from another session without making it global.

something like this

for I:=0 to sessions.Count -1 do begin

session.GetVariable['username'];

end;

 

Still not clear for me. How do you refer to other sessions? By Session Id? Do you keep a list of them?

 

Do you want to share a global variable among all sessions? If yes put it in servermodule and protect it by Lock/Unlock

Link to comment
Share on other sites

  • Administrators

In MainModule:

 

  TUniMainModule = class(TUniGUIMainModule)
 private
{ Private declarations }
 public
{ Public declarations }
MyVar : Integer;
 end;

 

In your code:

 


implementation

{$R *.dfm}

uses
 uniGUIVars, MainModule, ServerModule,  uniGUISessionManager;

procedure TMainForm.UniButton1Click(Sender: TObject);
var
 I: Integer;
 ASessionList: TList;
begin
 ASessionList := UniServerModule.SessionManager.Sessions.SessionList.LockList;
 try
   for I := 0 to ASessionList.Count - 1 do
begin
 	(TUniGUISession(ASessionList[i]).UniMainModule as TUniMainModule).MyVar:=10;
end;
 finally
UniServerModule.SessionManager.Sessions.SessionList.UnlockList;
 end;

end;

Link to comment
Share on other sites

Wow thank you very much

 

In MainModule:

 

  TUniMainModule = class(TUniGUIMainModule)
 private
{ Private declarations }
 public
{ Public declarations }
MyVar : Integer;
 end;

 

In your code:

 


implementation

{$R *.dfm}

uses
 uniGUIVars, MainModule, ServerModule,  uniGUISessionManager;

procedure TMainForm.UniButton1Click(Sender: TObject);
var
 I: Integer;
 ASessionList: TList;
begin
 ASessionList := UniServerModule.SessionManager.Sessions.SessionList.LockList;
 try
   for I := 0 to ASessionList.Count - 1 do
begin
 	(TUniGUISession(ASessionList[i]).UniMainModule as TUniMainModule).MyVar:=10;
end;
 finally
UniServerModule.SessionManager.Sessions.SessionList.UnlockList;
 end;

end;

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Correction:

 

   
for I := 0 to ASessionList.Count - 1 do
begin
       if not TUniGUISession(ASessionList[i]).IsTerminated then
  		(TUniGUISession(ASessionList[i]).UniMainModule as TUniMainModule).MyVar:=10;
end;

 

Hi, information like this one will be available in documentation? This kind of information is very useful.

 

thanks

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.

×
×
  • Create New...