Session Variables

Session Variables

Session Variables

Session Variables is an important feature in the Kuika platform that enables temporary storage of data. It can be used to securely hold and manage user session information. These variables allow you to personalize the user experience by storing information such as user ID, session state, preferred language. In web applications, it ensures that data is protected throughout the application lifecycle.

The content of this course consists of the following topics:

  • Add Session Variables to your application
  • Configure Session Variables settings
  • Data type management in Session Variables
Add Session Variables to Your Application
  1. Log in to the Kuika platform and open the project you will work on from the Apps screen.
  1. Open the Data Sources module. In this module you can view data sources, actions and tables and add a new data source.
  2. Click the three dots on the right edge of the Session Variables field and select Edit.
Configure Session Variables Settings

Fill in the fields in the modal as follows:

  • Key The key name that allows the variable to be defined (Example: user_id, language)
  • Value: The data that the variable will hold. (Example: 12345, English)
  • Read Only: Determines whether the variable is read only (if checked, the value of the variable cannot be changed during the session).

Add a new variable by clicking the ADD button and save it with the SAVE button.

Data Type Management in Session Variables

When using Session Variables in SQL queries, the data type of the returned data must match the data type expected by the SQL query. If necessary, you can perform data type conversion using the CAST function.

  1. In the Data Sources module, click the + icon next to the Actions title in the left panel.
  2. Select the New SQL Action option.
  3. Write your query using SQL Editor. (Example SQL query:)
SELECT CAST(SESSION_CONTEXT(N'user_id') AS NVARCHAR(100)) AS UserName;
  1. Save the query by clicking the CREATE button.

This method ensures that the Session Variable is processed with the correct data type.

Testing SQL Action

To test the defined SQL Action:

  • Run the SQL Action by clicking the Test button on the right sidebar.
  • Check that the query returns correct results based on the values from the Session Variable.
  • Make sure that the Session Variable values are dynamically flowing into the SQL query.

By following these steps, you can use Session Variables effectively in your applications.

Other Related Content

Glossary

No items found.

Alt Başlıklar