Reputation: 51
I am using grails 2.4.2 and I want to use session value from another session is this possible ? case is : i have a user when user is logged in and updates his profile then super admin will get notification for updated profile. For that purpose I have set variable as
String notification = session.count
session.count =Integer.parseInt(notification) + verify
where verify is the value of the updated profile
Now when superadmin is logged in I want to get the session.count
variable at the menu page is this possible without using session filters
how?
Upvotes: 0
Views: 165
Reputation: 20699
No, the sessions
are isolated. If you want to access the state set by one user from the session of another one, you have to use a more or less persistent storage:
You could store your vars in a DB or use a service
with a e.g. ConcurrentHashMap
:
class CrossContextService {
ConcurrentHashMap cache
}
class SomeController{
def crossContextService
def someAction(){
crossContextService.cache.count = ...
}
}
Upvotes: 1