In general, a session can be saved or loaded at any time, even if the user is not logging in or out.
In order for a session to include the state of an application, the application must be able to store and load its current state when appropriate.