Closed Shazwazza closed 2 years ago
(I also mostly wanted to report this in case other people are searching work arounds for this)
Thank you for opening the issue @Shazwazza and for taking the time to investigate the cause! We can treat this as a regression - cookies should just work and be enabled by default.
With the latest 1.7.x version the cookie jar (which is a ToughCookie instance) will not work unless it is specifically enabled. This means that if you have any JS that assigns a cookie to the request it will not work unless a previous response had a cookie, or your config has an explicit cookie defined. This is different than the prev 1.6.x version.
It's due to this code here: https://github.com/artilleryio/artillery/blob/v1.6.x/core/lib/engine_http.js#L262
To work around this you need to set a default cookie value, even if it's empty so the cookieJar is enabled. You can do this at top level of your config like:
or at request levels, etc...
If you do this, then the cookieJar is enabled which is this code: https://github.com/artilleryio/artillery/blob/v1.6.x/core/lib/engine_http.js#L653
There's another work around, which is to forcefully enable it in the beginRequest method like:
I think it may be clearer be able to explicitly enable this in config, something like
and perhaps you could have "auto" or even "never" (not sure why you'd want that, but maybe). Could be some other options like that but is a bit more clear that you just want to be able to dynamically set cookies in a request without having to declare an empty cookie.