session attributes showing incorrect values

First I save the session attribute named “profile”

.check(jsonPath("$.result").ofType[Map[String,Any]].find.saveAs(“profile”))

Then trying to set another session attribute “foo”

.exec(session => {
session.set(“foo”, “blablabla”)
session
})

Then I try to get this “foo”

.exec(session => {
println(session.get(“foo”))
session
})

But in fact I am getting the “profile” attribute

Besides, even when I do:

.exec(session => {
println(session.get(“doesnotexist”))
session
})

I get the same “profile” attribute

What’s going on?
Is it a bug?

http://gatling.io/docs/2.1.7/session/session_api.html#setting-attributes

TL;DR : Session are immutable, by adding session after your session.set(...), you discarded the session that contained the additional attribute.

thanks!

I am sorry, because this is duplicated question from

Not able to set session attribute