session is immutable, and you are using foreach which is a function that returns nothing. So the session that you return at the end of your exec is the same as the one you get at the beginning. Furthermore, that is not a correct way to seek an element in a Map.
And I don’t understand what you are doing : you are manually browsing a map, checking the value of the key and value, and if these are equals to what you want, you get another value with another key.
Why not just do
.exec { session =>
val id = maps.flatMap { case (_, map) =>
map.get("id")
}.head.toString
session.set("id_map", id)
}