Access an existing session

To allow a KCM Core job to access to an existing session, the session identifier must be passed from the client application to KCM Core when the job is submitted. This is similar to how the job ID is specified. The called job is then associated with the session that was specified, and the scripts are able to access the data stored in the session. You cannot associate with an existing session a job that is already running and not yet associated with any session. For more information on how to pass a session identifier to KCM Core when submitting a job, see the chapter Integration in the Kofax Communications Manager Core Developer's Guide.

When a script requires access to a session, you should always check that it is actually running in a session. To do so, test the value of _session_active, as shown in the following example.

If Not _session_active Then
  ThrowError Message("This service requires a session.");
Fi;

When a client application passes a session identifier to KCM Core that does not correspond to an existing session, the job proceeds to run normally. No error is generated. You should always include a check for an active session at the beginning of each script that requires the use of a session.

If the script is running in a session, it can use the data from the storage directory of the session, such as the file "data.xml" that was stored in the preceding example.

ITPRun
  Model("mymodel")
  Keys( "data.xml" [_sessiondir, ] );

The script can also retrieve string values from stored session parameters, as shown in the following example.

Var Text X = get_sessionparameter ("my_stored_info");  # returns "3.14"

KCM Core does not simultaneously run multiple jobs submitted with the same session identifier. If two jobs are simultaneously submitted with the same session identifier, they run in a series. The reason for this behavior is to prevent simultaneous access to the same session storage by multiple scripts. Such simultaneous access may lead to conflicts.

This serialization also takes place when the session identifiers of the submitted jobs do not correspond to valid sessions. This means that passing a fixed, non-empty session ID to jobs is currently not recommended, because the jobs are not able to use the resources of more than one Document Processor.