
WebSurge sessions support Session Variables that you can define in your Configuration and then use in your Http Headers or Http Request content.
Variables can be:
Session Variables
Variables declared in the Session Configuration. These are text values, or can be Windows Environment variables (%ENV_VAR%
).Environment Variables
Variables declared in the System environment and available when WebSurge is started. Note: If you change Environment Variables on the command line or in Windows you have to restart WebSurge to see those variables.
Session Variables are declared as Key Value pairs in the Session Configuration:
Variables that you define look like this:
userId=frankenUser#2
openAi-api-key=%OPENAI_KEY%
merchId: f24d1212221d9ea3
These variables can then be embedded into Http Headers or Http Request content and are specified using either a defined session key, directly embedding an Environment variable (%ENV_VAR%
):
Content-Type: application/json
Authorization: Bearer {{ openAi-api-key }}
x-merchant-id: {{ %MERCHANT_ID% }}
Creating Variables
To create variables you can go to the session configuration and enter them into the Session Variables
edit box, one line per variable. Variables can be in the following formats:
With @
prefix (Visual Studio style):
@varname=value
@token=x3dfeaea29jsg
@openAiKey=%OPENAI_KEY%
or without:
varname=value
token=x3dfeaea29jsg
openAikey=%OPENAI_KEY%
Common values here can be fixed user tokens, base urls or any other constant values that you might re-use across multiple requests, or need to customize depending on the target that the requests are running against.
Using Environment Variables
You can use Environment variables for variable names by wrapping the variable in
%ENV_VAR%
sytnax.
Using Variables in Requests
To use the variables in your requests you can embed them into the Url, Headers or Body of any request in the session.
For example in the body you might have:
{
name: "{{varname}}"
}
In a header you might replace a token.
Authorization: Bearer {{token}}
You can also use Environment variables directly:
Authorization: Bearer {{ %OPENAI_KEY% }}
© West Wind Technologies, 2025 • Updated: 2025-02-23
Comment or report problem with topic