Save and restore a session

You can archive and later restore the contents of a session. To save the contents of a session, use the command SaveSession.

The following example shows how the current session is saved to the archive file savedsession1 in the directory C:\SavedSessions. The stored information includes the contents of the directory _sessiondir and the stored session parameters.

 SaveSession
  Archive( "savedsession1" [ "c:\SavedSessions", "ses" ] );

After the command SaveSession completes, the session contents are stored in the specified archive. Furthermore, the session is cleaned up. This means that it is not possible to archive a session and then to continue working within that same session.

To restore the contents of an archived session, use the command RestoreSession. The following example demonstrates how the contents of the session that was saved in the preceding example are restored.

RestoreSession
   Archive( "savedsession1" [ "c:\SavedSessions", "ses" ] );

You can only use the command RestoreSession when the current job is not already associated with a session. The command creates a new session and associates it with the current job. It then restores the contents, such as files and session parameters, of the archived session into the newly created session. The new session is created with a new session identifier, not equal to the original session identifier of the session that was saved. After the command RestoreSession completes, the original session identifier of the restored session can be retrieved from the variable _restored_session. The variable _sessionid contains the new session identifier.

The archive file is compressed and its contents are optionally encrypted to protect any content included from the directory _sessiondir. A checksum is used to validate the contents before restoring a session.

Applications can add data to the end of an encrypted archive file without invalidating its contents. Non-encrypted archives should not be modified.

KCM ComposerUI

KCM ComposerUI uses the session to store answers to interactive screens and (optionally) cached data. This information is included when the session is saved or restored. When implementing a save/restore scenario, consider whether KCM ComposerUI caching should be enabled and possibly remove any cache files when restoring a session.