OpenWGA 7.0 - TMLScript reference

TMLContext "this"
Method :

setSessionVar(varname, value [, allowSerialisation])

On object TMLContext "this"
Usage Sets or updates a WebTML session variable
Description This is the TMLScript pendant to the WebTML attribute sessionvar. The WebTML variables set via this method persist until the end of the user session or until they are removed via this.removeSessionVar().

Like all other WebTML variables they can be retrieved via this.item() in TMLScript or <tml:item> in WebTML.

You can update existing WebTML session variables using the shortcut syntax described on the TMLContext object.
Parameters varname (String):
Name of the variable

value (Object):
Value of the variable

allowSerialisation (Boolean, optional):
Controls if this variable should be serialized to other cluster nodes in a server cluster. This is only possible if the value type is serializable. Defaults to true.
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
Examples The following example is a WebTML action that is setting a session variable called "bgcolor". This variable may be used to store a value for the background color of the website, that the user may choose. As it is a session variable the setting will persist for the time of the session, but will be gone on later sessions. The value of the variable is taken from an action parameter.

<tml:action id="setColor">
this.setSessionVar("bgcolor", this.tmlparam1);

This WebTML session variable could be used like in the following example via WebTML:

<body bgcolor="<tml:item name="bgcolor"/>">