# I can't seem to use Session Variables stored from a request in a subsequent Request

**URL:** <https://community.gatling.io/t/i-cant-seem-to-use-session-variables-stored-from-a-request-in-a-subsequent-request/5991>\
**Category:** Gatling (Open-Source)\
**Created:** [February 12, 2021, 1:29am UTC](https://community.gatling.io/t/i-cant-seem-to-use-session-variables-stored-from-a-request-in-a-subsequent-request/5991 "2021-02-12T01:29:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anand\_Patel](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@Anand\_Patel](https://community.gatling.io/u/Anand_Patel)\
**Post date:** [February 12, 2021, 1:29am UTC](https://community.gatling.io/t/i-cant-seem-to-use-session-variables-stored-from-a-request-in-a-subsequent-request/5991/1 "2021-02-12T01:29:08Z")

</div>

The code:

package simulations

import io.gatling.core.Predef.\_  
import io.gatling.http.Predef.\_

class StarWarsBasicExample extends Simulation  
{

// 1 Http Conf  
val httpConf = http.baseUrl(“[https://swapi.dev/api/films/](https://swapi.dev/api/films/)”)

// 2 Scenario Definition  
val scn = scenario(“Star Wars API”)  
.exec(http(“Get Number”)  
.get(“4”)  
.check(jsonPath("$.episode\_id")  
.saveAs(“episodeId”))  
)  
.exec(session =\> {  
val movie = session(“episodeId”).as[String]  
session.set(“episode”,movie)  
}).pause(4)

.exec(http("$episode")  
.get("$episode"))

// 3 Load Scenario  
setUp(  
scn.inject(atOnceUsers(1)))  
.protocols(httpConf)

}

Trying to grab a variable from the first Get request, and inject that variable into a second request, but unable to do so despite using the documentation. There might be something I’m not understanding.

When I use breakpoints, and navigate through the process, it appears the session execution happens AFTER both of the other requests have been completed (by which time is too late). Can’t seem to make that session execution happen between the two requests.

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [February 12, 2021, 7:11am UTC](https://community.gatling.io/t/i-cant-seem-to-use-session-variables-stored-from-a-request-in-a-subsequent-request/5991/2 "2021-02-12T07:11:38Z")

</div>

.get("$episode")) is not correct Gatling EL syntax. It should be .get("${episode}"))
