Naveen
Naveen

Reputation: 6936

Get all sessionScope variables in XPages

Lets say user A logs in and a sessionScope variable is set (This is just an example):

sessionScope.put("ABC", "ABC");

Now user B logs in and his sessionScope variable is set:

sessionScope.put("XYZ", "XYZ");

Is there a way where I can get all these sessionnScope variables/objects belonging to different users?

Upvotes: 0

Views: 2088

Answers (4)

Newbs
Newbs

Reputation: 1632

SessionScope variables belong to a single instance of a browser/client. If you are Anonymous and log in as "user one" you have the same sessionScope as you did before. The same is true if you logout and log back in as "use two".

I have built an app which runs a method in the before page load of every page to assure the necessary sessionScope data is setup. One part of that data is the name of the user for whom the data is defined. That way, if the user name changes the we clear the data and reload it for the current user.

Using this approach you could define a MAP or JSON object with the username as the key which would keep the differences as people log in and out, but I am not sure that is a very sensible thing to do since changing identities is only realistic in development and testing. It is not a normal thing in production.

/Newbs

Upvotes: 0

Tim Tripcony
Tim Tripcony

Reputation: 8086

In theory, you could register a sessionListener that stores in the applicationScope a pointer to each sessionScope that is created... but, in my opinion, that's a very bad idea. You'd have to be extremely careful to avoid exposing users' session data to each other.

Upvotes: 3

jjtbsomhorst
jjtbsomhorst

Reputation: 1667

Session scopes belong to a single user so you cant retrieve them out of the box. You could add logging to the xpage/business log so you can keep track of the things that are going on. Another approach is to login as the user where you want to now the scopes from and use the debugbar to investigate

Upvotes: 1

Related Questions