How is it possible to share values/variables among two sessions in gatling?


We have a scenario in which the user performs to consecutive requests, which will be like this is pseoducode:

  1. http(POST): /createUserSession /* returns a userSessionId */
  2. http(POST): /ceateShoppingCart
    .queryParam(“sid”,userSessionId) /* create a shoppingCart using the userSessionId)

I tried to store the userSessionId as session variable in the first request, and then pass it as a parameter in the second request:

val search =
.exec(session => {session.set(“session_id”, ((parse(userSessionId…)) /* catching the userSessionId in the first request */

.queryParam(“sid”,session(“userSessionId”).as[String] ) /* passing the stored userSessionId in the second request */

However the second request fails as the passed userSessionId is always null, as if it is working with a new session who does not have the userSessionId.
In gatling, is a SESSION created for each USER, or each REQUEST? Does the second request create a new session?
How can I share session variables between consecutive requests of a single user?

Would highly appreciate any help!