04-07-2023, 08:50 PM
(This post was last modified: 04-07-2023, 09:00 PM by Alexandre Machado.)
You need to declare a variable of type TIWUserSession to assign the value to.
In the example above I used UserSession but probably the compiler is trying to use the UserSession function. Use a different name instead:
as I mentioned before, I'm assuming you have access to the WebApplication. If not, use gGetWebApplicationThreadVar() instead. The complete code should be:
In the example above I used UserSession but probably the compiler is trying to use the UserSession function. Use a different name instead:
as I mentioned before, I'm assuming you have access to the WebApplication. If not, use gGetWebApplicationThreadVar() instead. The complete code should be:
Code:
uses
UserSessionUnit, IWApplication;
procedure DoSomethingWithUserSession();
var
WebApp: TIWApplication;
theUserSession: TIWUserSession;
begin
WebApp := gGetWebApplicationThreadVar();
theUserSession := nil;
if Assigned(WebApp) then // there is no guarantee that a TIWApplication instance exists when an exception is raised
theUserSession := TIWUserSession(WebApp.Data);
if Assigned(theUserSession) then
begin
// do what you have to do with the UserSession here
end;
end;