title: How to pass a session variable from one object to another in Gatling?
body: <p>I'm extracting session variable in ObjectA and would like to pass it to ObjectB, what is the best way to achieve this?</p>
  
  <pre><code>object ObjectA {
    val foo = exec(jsfPost("Request1", "/something.xhtml")
          .formParam("SUBMIT", "1")
          .check(regex("""Count:([^:]*),""").saveAs("Count"))
          )
         .pause(1)
         .exec { session =&gt;  
            val Count = session("Count").as[String].toInt
            val GroupName = SomeCustomFunc(Count)
          }
          .exec(ObjectB.bar)
  }
  
  object ObjectB{      
    val bar = group(GroupName){
        myChain
    }
  }
  </code></pre>
  
  <p>Pretty sure I'll feel stupid after seeing the answer, but so far did not managed to get this working.</p>
  
  <p>Answer: As Stephane suggested passing through Session worked fine:</p>
  
  <pre><code>object ObjectA {
    val foo = exec(jsfPost("Request1", "/something.xhtml")
          .formParam("SUBMIT", "1")
          .check(regex("""Count:([^:]*),""").saveAs("Count"))
          )
         .pause(1)
         .exec(session =&gt; session.set("GroupName", SomeCustomFunc(session("Count").as[String].toInt)))
         .exec(ObjectB.bar)
  }
  
  object ObjectB{      
    val bar = group("${GroupName}"){
        myChain
    }
  }
  </code></pre>