# How to get a session value before HTTP request?

**URL:** <https://community.gatling.io/t/how-to-get-a-session-value-before-http-request/3042>\
**Category:** Gatling (Open-Source)\
**Created:** [May 31, 2016, 6:31pm UTC](https://community.gatling.io/t/how-to-get-a-session-value-before-http-request/3042 "2016-05-31T18:31:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Sun](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Richard\_Sun](https://community.gatling.io/u/Richard_Sun)\
**Post date:** [May 31, 2016, 6:31pm UTC](https://community.gatling.io/t/how-to-get-a-session-value-before-http-request/3042/1 "2016-05-31T18:31:19Z")

</div>

From document, the solution to get a value from session before http request is passing a function, but I not sure how to use it.

> This Expression Language only works on the final value that is passed to the DSL method when the Simulation is instantiated.
> 
> For example, `queryParam("latitude", "${latitude}".toInt + 24)` won’t work, the program will blow on`"${latitude}".toInt` as this String can’t be parsed into an Int.
> 
> The solution here would be to pass a function:
> 
> `session => session("latitude").validate[Int].map(i => i + 24)`

I have a loop, and I want to get the loop number before http request. Idealy the code should be :

> > repeat(loop, “n”){
> 
> > MyCase(“sessionKey\_${n}”)
> 
> > }

But it won’t work base on above explanation, so how to apply the function solution here?
