SetAttributes

Specify one or more session attributes and their values.

$webinfo("SESSIONCOMMANDS"), "SetAttributes",AttributeList

Parameters

AttributeList—associative list of one or more Attribute=Value pairs:

"Attribute=Value {;Attribute=Value}"

  • Attribute—name of an session attribute; case-sensitive. If no attribute of that name exists, it is created.

  • Value—value of the session attribute.

Description

You can use the SetAttributes command to associate additional information with the session.

Session attributes are like variables that are available on the WRD for the duration of the session. They can be used to share session information between different server pages.. For example, if a user has been authenticated with a specific role, that information can be stored in as session attribute and referenced by another component that needs to verify that the user has the correct role. Or consider a web shop application—a search profile or shopping cart contents can be stored in session attributes so that it is available to various server pages the user accesses.

SetAttributes is executed on the current session. If the previous ChangeSession command was a CLOSE action, the SetAttributes command is ignored.

Defining and Setting Session Attributes

; Create a list of Session attributes and their values
putitem/id vAttList, "DATA1", "New"
putitem/id vAttList, "Data2", "Edit"

; Add the command and its parameters to the SESSIONCOMMANDS chanel of $webinfo
putitem/id $webinfo ("SESSIONCOMMANDS"), "SetAttributes" , vAttList