problem with set variable on session, need explanation

I am new to gatling
I am trying to loop on json response, find the country code that I am looking for and take the id coressponding the that coutry code.
Sample algorithm:
list.foreach( value => { if (value.coutrycode == “PL”) then store value.id })

on Gatling:

def getOffer() = {
exec(
http(“GET /offer”)
.get("/offer")
.check(status.is(Constant.httpOk))

.check((bodyString.exists),
jsonPath("$[*]").ofType[Map[String,Any]].findAll.saveAs(“offerList”)))
.foreach("${offerList}", “item”){

exec(session => {
val itemMap = session(“item”).as[Map[String,Any]]
val countryCodeId = itemMap(“countryCode”)
println(“" + countryCodeId)
// => print all the country code on the list
if (countryCodeId ==“PL”){ // if statement condition
println("
*********”+ itemMap(“offerd”)); // print the id eg : “23”
session.set(“offerId”, itemMap(“offerId”)); // set the id on the session
}
println("$$$$$$$$$$$$$$" + session(“offerId”)) // verify that th session contains the offerId but is not
session
})
}
}

When I try to print the session(“offerId”), it’s print “item” and not the offerId.
any explanation of this behaviour please ?

Please read the documentation: https://gatling.io/docs/gatling/reference/current/session/session_api/#setting-attributes

I tried with session(“offerId”).as[String] but I got No attribute named ‘offerId’ is defined’