Saving and restoring sessions

It is possible to archive and later restore the contents of a session. Saving is done using the command SaveSession. The following example saves the current session to the archive file savedsession1.ses 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 successfully, the session contents will have been stored in the specified archive. Furthermore, the session will have been cleaned up, exactly like the command CleanupSession would do. 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 restores the contents of the session that was saved in the preceding example.

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

The command RestoreSession can only be used when the current job is not already associated with a session. The command creates a new session and associates it with the current job (exactly as if the command CreateSession had been used). It then restores the contents i.e., 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 will contain 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.

ITP/OnLine
ITP/OnLine 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 it should be considered whether or not ITP/OnLine caching should be enabled and possibly remove any cache files when restoring a session.