Session.set doesn't work?

Hi,

I’m using Gatling 2.0.0 SNAPSHOT, i tried to set session as below:

.exec(session => {
session.set(“myValue”, “1234”)
session
})
.exec(session =>{
println(“myValue”)
println(session(“myValue”).as[String])

session
})

But it throws exception:
“…akka://GatlingSystem/user/$g] key not found: myValue”

How can I resolve this?

Thanks in advance.

I removed session in the first exec and it works now.
exec(session => {
session.set(“myValue”, “1234”)
//session
})

And to answer the question in your post title : Session.set does work but, as it is stated in the documentation (https://github.com/excilys/gatling/wiki/Session#immutability), Sessions are immutable.
Session.set returns a new Session, with your key set in it.
With your previous code, you returned the previous session, and the result of Session.set, e.g. your Session with the new key set, was discarded.

Got it, thanks Pierre.