# Update session variable

**URL:** <https://community.gatling.io/t/update-session-variable/3783>\
**Category:** Gatling (Open-Source)\
**Created:** [June 21, 2017, 11:29am UTC](https://community.gatling.io/t/update-session-variable/3783 "2017-06-21T11:29:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avenir\_Voronov](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@Avenir\_Voronov](https://community.gatling.io/u/Avenir_Voronov)\
**Post date:** [June 21, 2017, 11:29am UTC](https://community.gatling.io/t/update-session-variable/3783/1 "2017-06-21T11:29:14Z")

</div>

Hello,

I’m trying to change variable

val scn = scenario(“RecordedSimulation”)  
.exec(http(“request\_0”)  
.post("/path")  
.check(jsonPath("$.some\_token").saveAs(“token”))  
)  
.exec( \_.set(“token”, “some phrase” + “$token”)  
.exec(session=\>{  
val maybeId = session.get(“token”).asOption[String]  
println(maybeId.getOrElse(“COULD NOT FIND ID”))

session  
})

But it prints  
some phrase$token

I tried  
.exec( \_.set(“token”, “some phrase” + “${token}”))  
shows  
some phrase${token}

I tried

.exec( session=\> {  
session.set(“token”, “some phrase” + session.get(“token”).asOption[String])  
})

returns  
some phrase Some(ldskjgfdslkjgolds)

I tried

.exec( session=\> {  
session.set(“token”, “some phrase” + session.get(“token”).asOption[String].getOrElse(“COULD NOT FIND ID”))  
})

and got result that I want

some phrase ldskjgfdslkjgolds

But is there any other short method to get such result?
