Scripting examples on how you can interact with cookies during your load test if required.
As HTTP is a stateless protocol, cookies are used by server-side applications to persist data on client machines. This is used more or less everywhere on the web, commonly for user session tracking purposes. In k6 cookies are managed automatically by default, however, there are use cases where access to read and manipulate cookies are required.
The console.log() family of APIs are currently only usable when running k6 locally. When running k6 tests with LoadImpact Cloud Execution the logs will be discarded.
To set a cookie that should be sent with every request matching a particular domain, path, etc. you'd do something like this:
To delete a cookie in the jar for a specific URL and name, use the delete method.
To clear all cookies in the jar by specifying url, use the clear method.
Relevant k6 APIs: