How to get a session value before HTTP request?

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?