Add second cookie to session.

Hi (Gatling 2, I have read documentation)

I need too add second cookie to each header. For now I am able to add it as a static value in header.

val header_with_secondCookie = Map("Cookie" -> "firstCookie=01; secondCookie=${secondCookie}")
  

val postLoginAndPass = exec(
  http("request_1").post(uri2 + "/json/authenticate").headers(header_with_default_cookie)
    .body(ElFileBody("authBody.json")).asJSON
    .check(jsonPath("$.tokenId").saveAs("secondCookie"))   
)

val schouldGetWithNewSecondCookie = 
  exec(
    http("request_2")
    .get(uri2 + "/user")
    .headers(header_with_secondCookie)
  )

Maybe there is some way to add second cookie to session…?

After DEBUGGING session I noticed that method
exec(flushSessionCookies) works. Session cookies are dropped.

Now I need to add new cookie inside session, but method
exec(addCookie(Cookie(“name”, “value”))) does not work at all.

val scn = scenario("BasicSimulation") .exec(http("request_1").get("/")) .exec { session => println("My session before: " + session) session } .exec(addCookie(Cookie("name", "value"))) .exec { session => println("My session ater: " + session) session }

So, sessions before and after are identical. No changes.
How to add cookie to session manually, when addCookie figure doesn’t help.


Hi,

What version of Gatling are you using ? This was a bug in previous versions that was corrected in 2.1.6 or 2.1.7.

Also, addCookie won’t work without a baseURL set on the protocol level.

Cheers.

<properties>
   <maven.compiler.source>1.7</maven.compiler.source>
   <maven.compiler.target>1.7</maven.compiler.target>
   <scala.version>2.11.7</scala.version>
   <encoding>UTF-8</encoding>

   <gatling.version>2.2.0-M3</gatling.version>

   <scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>
</properties>

Could you give me some tip how to set up baseURL and cookie together into the session?

My Cookie jar is sth like

`

gatling.http.cookies → CookieJar(Map(CookieKey(amlbcookie,my.domain.com,/) → StoredCookie(amlbcookie=01; domain=my.domain.com; path=/,false,false,1446644285856))))
`

And I need to add second cookie (or replace old one)

myNewCookieToken=${myNewCookieTokenValue}

W dniu czwartek, 5 listopada 2015 09:30:16 UTC+1 użytkownik Guillaume Corré napisał:

We release milestones for our customers when they need them.
You can use them, but at your own risks: they are not documented, and might contain bugs that are fixed in the master and/or the latest stable version (which is currently 2.1.7).

Thanks for explanation.

After downgrade to 2.1.7 everything is OK.

W dniu czwartek, 5 listopada 2015 11:14:27 UTC+1 użytkownik Stéphane Landelle napisał: