The session scope is ideal for storing information about the current user of an application. For many applications, whenever we need to store this kind of information we just store it directly in a session variable:
- session.userId – the user’s Id
- session.roles – list of roles the user is fulfilling
- session.permissions – struct of permissions for the user
- session.lastSearchResult -query with the results of a recent search
- etc.
Sometimes, this data is wrapped up in a “user” struct and stored in the session:
- session.user.userId
- session.user.roles
- session.user.permissions
- session.user.lastSearchResult
- etc.
Session data is available globally which means that any page, custom tag or component can immediately access it. This provides a great convenience as the data is very simple to access; if you need the current user’s id just grab session.user.userId.
However as the number of session variables increases and the number of pages that access them grows this data can become very difficult to manage. We may have so many session variables that the purpose of some of them is difficult to determine. We may need to make some changes to the structure of some of these variables. For example, a variable may need to be renamed due to a change in the system design, another variable needs to be changed from a list to a struct, another variable may have become obsolete and needs to be removed. These types of changes can be quite complex to make due to their widespread global nature. In even medium size systems changes such as there are often so difficult that they cannot be performed.
There are some object oriented concepts can assist in making these types of problems more manageable.
Continued here: Accessing a Users’ Session Data

Glyn Jackson · August 16, 2009 at 7:27 pm
Thank you for the write up it now makes more sense.
Reinhard Jung · October 15, 2009 at 4:50 pm
Cool. Thanx for this Entry!!!
Reinhard Jung · February 25, 2010 at 11:24 am
Nice!