Programming Guide


Creates a context global variable

#include <smuweb.h>
int sm_web_save_global(char *variable_name);

Name of the JPL global variable to be designated as a context global.





sm_web_save_global designates a JPL global variable as a context global. Each context global is private to a single user of a Web application server and is automatically cached until it reverts to a transient global or the application exits. Before calling this function, create the global variable with the global command.

A context global can save user-specific information such as ID, preferences, or start time. The value of the variable is cached before Panther generates the HTML for the screen; the value is restored from the cache file when the screen is submitted back to the server.

If the global command executes a second time, it overwrites the global's previous value. If you execute the global command in the unnamed JPL procedure or during screen entry, also test whether the screen is being opened for a GET event, because the screen is then reopened on a POST event. You can test this by using the K_WEBPOST flag or the CGI variable @cgi_request_method.

For more information about using JPL global variables in a Web application, refer to Chapter 7, "JPL Globals in Web Applications," in Web Development Guide.


// Call on application startup.
proc setup()

// Create global variables if they do not already exist.
if (sm_web_save_global("pref_lang") < 0)
global pref_lang(15), pref_textonly(1), pref_maxrows(1)
call sm_web_save_global("pref_lang")
call sm_web_save_global("pref_textonly")
call sm_web_save_global("pref_maxrows")

// Initialize the preferences to the default values.
pref_lang = def_lang
pref_textonly = def_textonly
pref_maxrows = def_maxrows

See Also

sm_web_unsave_global, sm_web_unsave_all_globals