Creating a session

Normally, when an ITP/Server job starts it is not associated with a session. A script can choose to create a new session using the command CreateSession:

CreateSession;

When the command CreateSession completes, the running job is associated with a newly created session, and ITP/Server will have generated the following;

The script can store persistent data into the session directory, for instance an XML file received from the client application:

ReceiveFile
  Src("data_for_the_session.xml")
  Dest("data.xml" [_sessiondir,]);

This example requests a file from the client application and stores it in the file "data.xml" in the session directory. It is also possible to store single string values into the session. For instance, this command stores the value " 3.14" in the session parameter my_stored_info.

SetSessionParameter
  Par ("my_stored_info")
  Value ("3.14");

The stored data will remain available until the session is explicitly cleaned up. To be able to gain access to the session at a later time, it is important to store the session identifier, which is the key by which the session is accessed. This is normally done by sending the session identifier to the client application using the function exchange_data:

Var Text Dummy = exchange_data ("SessionID", _sessionid, 0);

The client application must store the session identifier appropriately, so that it can pass it to subsequent ITP/Server jobs that require access to the data from the session.