Problem:
How to assign or determine the client-id that is required for a server-side file in a web application.
Resolution:
Look under Help>Programming>Distributed Computing>Part 8: CGI-based Applications>Part 32: Server-side programming>Maintaining Application State>The Server-side State Mechanism for a complete overview of this topic.
Basically the set of MF_CLIENT_STATE callable routines can be used to manage the state for each client (Browser) session that invokes the CGI program.
When the client starts the browser and the HTML page executes the server side CGI program for the first time, the CGI program can use a call to MF_CLIENT_STATE_FILE which will return a unique client-ID and will allocate the state record used by the calls.
The client-ID is then stored within a cookie on the form so it will be passed back to the server each time a new form is posted.
This information is all stored on the server and it is accessed by the client-ID that is generated.
The same browser session will always maintain the same client-ID even across multiple postings of the input form.
Here is the basic flow:
Specify the name of the state file.
Call the "MF_CLIENT_STATE_FILE" routine.
If this is the first time in, allocate a new client id, by calling the "MF_CLIENT_STATE_ALLOCATE" routine, then initialize a cookie or hidden control, then go to step 6.
If this is not the first time in, read the client id from the cookie or hidden control returned by the browser and continue at step 3.
Read the record for the client id.
Call the "MF_CLIENT_STATE_RESTORE" routine.
Read and process the input form, using the state information as needed.
Save the client state.
Call the "MF_CLIENT_STATE_SAVE" routine.
Return the next form to the browser.
This is directly out of the referenced section in the Net Express help.
