How can I get an object attribute into a foreach execution?

In the following code loggedUsers is a list o objects (Users) with some properties including its authentication cookie.
How can I access each user propertie into the scenarios chain?

`

val searchMessage = scenario(“searchByMessage”).feed(searchFeeder).foreach(loggedUsers, “logged_user” ){
exec(setSessionCredentials.setTokenAndCookie)
.exec(searchByMessage.browse)}

object setSessionCredentials {
val setTokenAndCookie =
exec{ session =>
val user = “logged_user”
session.set(“fullCookie”, loggedUsers.userCookie)
session
}

`


Hi!

The easiest way is to use Expression Language: https://gatling.io/docs/current/session/expression_el/#expression-language

Another way is to get object from session manually using session API: https://gatling.io/docs/current/session/session_api#getting-attributes

In your case adding cookie is a no-brainer using this piece of docs: https://gatling.io/docs/current/http/http_helpers#adding-a-cookie

Good luck!