You could write a Java action with no inputs and use this.getContext().getSession()
and return the session object.
Why would you need the session anyway?
EDIT: I once solved such a requirement in the following manner:
Whenever I needed to use the information in that non-persistent object, I would:
public class GetSessionIdentifier extends UserAction<string> { public GetSessionIdentifier() { super(); }
@Override public String executeAction() throws Exception { // BEGIN USER CODE return this.getContext().getSession().getId().toString(); // END USER CODE }
/**
// BEGIN EXTRA CODE // END EXTRA CODE }
In addition to Rom's comment, depending on your requirements you can also use the Session entity in the System module.
In some projects I had to use references from my data to the user that was logged in, but since 1 user account can have parallel sessions, we couldn't use the System.User entity.
We enable persistentSessions in the platform (PersistentSessions=true) and just did a database retrieve to find the session object from the user.
Just one side-note about associating object to user or session. The platform garbage collection is based on objects that are no longer 'accessible'. If you associate object to user or session, those objects are always accessible. Therefore any objects associated to session or user will never be cleaned up by the platform (this is desired behavior), until logout.
If you want objects to be cleaned up by the platform you should remove them yourself or reset the association.