Setting up CGI Link Session Data
To use session data in your application, add a CGI Link Session Data part to any empty area of the free-form surface. You can add a CGI Link Session Data part to any page in your application that needs access to the session data.
After you add the CGI Link Session Data part, you must open the settings of the part in order to specify what Smalltalk class you want to use for the value attribute of the CGI Link Session Data part. For example, if you want to store a user name in the session data, you would probably specify a String. After you have specified the class, you can tear off the value attribute of CGI Link Session Data in order to get full access to the object.
Each application can have only one session data object, so you must specify the same CGI Link Session Data value class in every page that uses the session data. If you need multiple persistent Smalltalk objects, define a composite class with whatever instance variables you need. You can then use your composite class for the value of CGI Link Session Data.
Example: Adding CGI Link Session Data to the To-do List
The To-do List example application uses a CGI Link Session Data part to maintain the contents of the list. This prevents the list from being destroyed and reinitialized each time the page is built. To set up the CGI Link Session Data part, follow these steps:
1. Open the properties of the CGI Link Session Data part.
2. For the valueClass field, specify OrderedCollection (this is the default, so you shouldn't need to change it). This indicates that this CGI Link Session Data part will be used to contain this type of object.
3. After you close the settings, tear off the value attribute of the CGI Link Session Data. The torn-off attribute should appear as a variable representing an OrderedCollection, with all of the attributes, actions, and events of that class.
After you have added the form data and session data parts to your application, it will look similar to the following:
Clearing session data
It is often useful during testing or demonstrations to be able to reset the session data in an image. Web Connection includes a widget interface and a Web part which add this capability. Both classes are in the
AbtWebSampleCatalogApp application. The start the widget interface, open the
AbtWebSampleClearSessionDataUserInterface class and select
the test button. The window shows the total number of session data elements ever created and the current number in the buffer. When session data elements time out, they are moved to the buffer. You can use the tool to refresh the values displayed, reset the session data, and inspect the session data dictionary. The Web part version of the tool is
AbtSampleClearSessionDataPage. You can refresh values displayed and reset the session data using the Web part.
Last modified date: 06/24/2018