Context variable

Introduction

In web applications where users are authenticated, a common procedure is to store user information in the Web Session. In many cases, that information is used to restrict the information that the user can access, defining the user's "context". In some cases the context may be defined by the user's name, while in others the context can be determined by the user's name and additional information: the user's company, or the section where he works.

Context information in K2BTools

K2BTools defines an SDT for that purpose, named K2BContext, that is created when K2BTools is used for the first time. This SDT can be modified by developers to meet their needs, by adding new fields to the SDT.

K2BContextVariable
Sample context variable

Also, two procedures are imported in the KB: K2BSetContext procedure and K2BGetContext procedure. Those procedures save and restore the SDT's value from the web session.

When using K2BTools' patterns, an instance of this SDT is stored in the web session, and is retreived automatically (using K2BGetContext) by K2BTools when an object is opened.

As the SDT instance is read when the user accesses an object, the developer may use the information stored in the SDT in the object's logic. For example, the developer may use information stored in this SDT to create conditions in the Web Panel.

The information stored in this session variable is not altered by K2BTools. The developer can store information in that variable using the K2BSetContext procedure.

NOTE: When the GAM integration module is imported a custom version of this SDT is imported alongside other objects. This is intentional, as that module writes information to the SDT.

If fields were added to the SDT prior to the module's import process, those fields must be created again before continuing.

Do NOT delete the fields created by the GAM integration module, as the module relies on their existence.