Retrieving cookie the use the value as a query param for subsequent requests

Hi guys,

I’m using gatling to run a load test against our production environment (at peak → 1500 req/sec) and the tool looks pretty god. Congrats!

I’m blocked because I don’t know how to retrieve a cookie from the cookie store and save the value in the session to use it for the subsequent requests. I thought that cookies will be available using the ${)…

Could you help me with this?

Thanks in advance!

Pedro

Just to mention that I’m using v2.0.0-M3a

Hi

I'm using gatling to run a load test against our production environment
(at peak -> 1500 req/sec) and the tool looks pretty god. Congrats!

Thanks!

I'm blocked because I don't know how to retrieve a cookie from the cookie
store and save the value in the session to use it for the subsequent
requests.

Cookies handling is enabled by default. If you don't get the expected
cookies in the subsequent requests, that's most likely a bug. If so, please
open an issue on Github, with the Set-Cookie header, the original URI and
the subsequent requests URIs that should send the cookie.

I thought that cookies will be available using the ${<cookieName>).

Nope. Cookies are not directly exposed in the session. The cookie jar
instance is stored with the key gatling.http.cookies. See the
io.gatling.http.cookie.CookieJar class for more info.

Thanks for the quick reply Stéphane!

Hi

I’m using gatling to run a load test against our production environment (at peak → 1500 req/sec) and the tool looks pretty god. Congrats!

Thanks!

I’m blocked because I don’t know how to retrieve a cookie from the cookie store and save the value in the session to use it for the subsequent requests.

Cookies handling is enabled by default. If you don’t get the expected cookies in the subsequent requests, that’s most likely a bug. If so, please open an issue on Github, with the Set-Cookie header, the original URI and the subsequent requests URIs that should send the cookie.

No, that isn’ the case. The cookies are being passed to the subsequent requests. I just want to retrieve a value from an existing cookie to use it as a query param, but I already have the solution.

.exec( session => {
import io.gatling.http.cookie._
import java.net.URI

val ck = session(“gatling.http.cookies”).as[CookieJar].get(URI.create(“”)).find(
_.getName ==
)
session.set(, ck.getOrElse(null).getValue)
})

I thought that cookies will be available using the ${).

Nope. Cookies are not directly exposed in the session. The cookie jar instance is stored with the key gatling.http.cookies. See the io.gatling.http.cookie.CookieJar class for more info.

Could you help me with this?

Thanks in advance!

Pedro


You received this message because you are subscribed to the Google Groups “Gatling User Group” group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi guys,

I’m using gatling to run a load test against our production environment (at peak → 1500 req/sec) and the tool looks pretty god. Congrats!

I’m blocked because I don’t know how to retrieve a cookie from the cookie store and save the value in the session to use it for the subsequent requests. I thought that cookies will be available using the ${)…

Could you help me with this?

Thanks in advance!

Pedro


You received this message because you are subscribed to the Google Groups “Gatling User Group” group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks,
Pedro

Cool then!
Note that we’ve simplified CookieJar in master so you’ll be able to write: session(“gatling.http.cookies”).as[CookieJar].store(“domain”)

Nice!

Thanks Stéphane!