A Session in Postman is a transient layer that holds your variable values related to your current working instance by allowing you to work with certain variables that remain local to your individual scope. Sessions resolves few complications in relation to collaboration and teamwork due to sensitivity of data surrounding the variables.
Sessions in Postman brings a host of capabilities. Some of them are outlined below:
As discussed, a Session is a local instance to a user in a workspace context wherein you can easily modify variables and Postman will not sync data to the servers keeping it strictly relevant to a local context. A Session in Postman holds the values of variables – environment, global, and collection. Simply put, Sessions comes in handy whenever a CRUD operation is involved. Sessions feature influences the following three aspects of Postman:
The next section outlines how you can assign current values to these variables using the Postman UI and get to your task while working with Collection variables, Environment variables and Global variables. You can assign a current value to your variables in the following ways:
To assign a current value, click ellipses (…) in the sidebar and select Edit to go to the Edit Collection screen as illustrated below. If you are not keen on working with a current value, you can leave the current value field empty and the old behavior of Postman will take precedence wherein your initial value would be treated as your current value.
Click Variables in the Edit Collection screen to bring up the following screen:
The above interface enables you to specify a current value that is relevant to your local context only. However, Postman provides you an option to replace your initial value with the current value. As current values are never synced to the Postman’s servers, shared data like your ‘initial value’ remains always intact unless you choose to explicitly sync using the Persist option.
Let’s add another four variables Token2, Token3, Token4 and Token5, assign some current values to understand the behavior of variables and how they work in the overall Postman context. The variables and their assigned values now look like this:
As you can see, the above interface contains five variables in total, with each having its current value. To persist your current value with the initial value, all you need to do is click Persist All. Clicking Persist All in the above screen results in populating the initial values with the current values for Token1, Token3, and Token5, as illustrated in the below screen.
You can see Token1, Token3, and Token5 populated with their current values in the Initial value field. You can also see Token2 and Token4 are disabled variables for which the Initial value field still has no value. It is because you will not be able to persist the current values of disabled variables even with Persist All option.
To persist your current value with the initial value for the disabled variables, point your cursor to the ellipses (…) and select Persist or Reset based on your need, as illustrated in the above screen. To delete the entire row, just click ‘x’. Reset All resets all the values.
Note: The Auto-Persist option does not work in the above context. For more information on Auto-Persist option, refer to the section Auto persisting variable values
The Sessions feature also enables you to assign current values to your variables – both environment and global. This section explains how you can assign current values to these variables.
You can assign a current value to the environment variables by
Using Quick Editing Option
To quickly edit the environment variable, ensure your environment is selected in the following drop-down.
Click Quicklook to bring up the following screen:
Point your cursor to the current value of Token1 to enable the edit icon as shown below:
Clicking edit icon will make the current value field editable as follows:
Enter your current value.
Editing Manage Environment screen
Select the corresponding environment in the Postman main screen and click Quicklook icon. The following screen appears:
Click button on top right corner (the button at the bottom belongs to Global variables) to bring up the Manage Environment screen:
Click the Current Value field and assign a value.
Editing Global Variables
Click the gear icon in the Postman main screen to go to the screen below:
Click Globals button to bring up the Manage Environments screen as illustrated below.
Go ahead and assign a current value.