A session is nothing but a temporary layer that holds variable values that are useful for the currently working instance and are local to your individual scope. In POSTMAN you have the facility of changing the value of the session variable and your work can be shared among your teammates without the need for sharing the values of the session variables.
POSTMAN allows you to share the session locally and even when you share the collection with the teammates, the sessions are not shared. When teamwork is carried out, then there are different tokens that have to be generated by the concerned company.
Now, these tokens are generated by the company after the Oath 2.0 Authorization by accepting the client-id or any personal-id. Therefore, this session contains confidential values that should not be shared with the team members even.
The different reasons for which sessions are useful are below :
A session is a local instance to a user in a workspace where the user can modify variables and it is made sure in POSTMAN, that data the user works with will not be synced with the server.
A session in POSTMAN holds the global variables, environment variables, and global variables. When CURD(Create Update Read Delete) operations are involved, the session is really easier to handle.
This can be done in the two following ways:
To assign a current value, click the three-dot (...) option which is beside the collection name. And then select Edit.
After clicking the Edit option, you will see a window for editing your collection. There are various options such as Descriptions, Authorizations, Pre-request Scripts, Tests, Variables, etc.
Select the option Variables. Inside that, you will get different values like:
Now, here you will be set your new variable name, the initial value, and the current value. For example, the variable name is Token1 and the value in the current section can be a token value like:
As shown in the above image, the current value is used in the local only. Also in POSTMAN, you will be able to change or replace the initial value with the current value. It should be noted that the current values are never synchronized with the POSTMAN's server. Also, the shared data like the initial value remains intact until and unless you use the Persist option to explicitly sync with the POSTMAN's server or any other server.
The current values are not synced with the server and do not affect the other collaborations while working in a team under the same workspace.
Let us create five different variables : Token1, Token2, Token3, Token4, and Token5. We shall initialize five different values into these tokens just for the sake of explanation.
As shown in the above image, we have declared five variables: Token1, Token2, Token3, Token4, and Token5. Now the variables, are assigned with an initial value and a current value. Now, as you can see in the above image, in the top right corner, there is an option called Persist All.
The Persist All button will work only when the values are selected. As in our cases, in the above image, Persist All will work as none of the variables are selected.