access gatling session data from the scala code

Hello,

I need to use some data from the gatling session in my code not related to gatling methods.
For example I set the passengerNumber first:

exec(session =>
session
.set(“passengerNumber”, “1”)
)

Somewhere later in the code I need to check the passengerNumber:

val pax = “${passengerNumber}”

if (pax.equals(“1”)) {
// do something
}

Is it possible to do it?

Thanks,
Elena

Yes and no. Look at “doIf” in the documentation. If you want anything more complicated, you will need to dive deeper into how things work.

“doIf” will not suite me as I need to use the session data in my custom code. I saw some post from you about your implementation of SessionManagement. Will look then further into that. Did not get yet how to implement it.

"doIf" will not suite me as I need to use the session data in my custom
code.

Yes it does:
http://gatling.io/docs/2.1.3/session/expression_el.html#expression