Common JMeter question – I would like to understand and see an example to use HTTP Cookie Manager and explain the different reasons I might use it.
- Store Cookies: HTTP Cookie Manager automatically stores cookies and will use it for all future requests to that particular website
- Threads and Cookies: Each JMeter thread has a separate “cookie storage area” and stores cookies specific to a thread/user. Let’s say if you are running a JMeter test for multiple threads/users then it will store cookies separately for each user (for example session cookie)
- Properties: JMeter allows altering the default behavior/configurations of cookies manager by changing its properties value for example:
- save.cookies=true/false (set it to true if you want to keep cookies as variables)
- check.cookies=true/false (set it to false if you want to store cross-domain cookies and might use them later)
- Custom Defined: Cookies Manager allows you to add a cookie manually. Manually added cookies will be shared by all threads/users
- this has real consequences on how cookies are managed and sent via your web requests
- We primarily stay with the default to simulate a browser as close as possible.
Example Plans – HTTP Cookie Manager
We built two test plans to show you the difference with and without CookieManager. The test performs a login and looks for validation that the user is logged in.
Test Plan with CookieManager Enabled
Please try to run and you will notice that your test case will pass. You can see this behavior in “view results tree.”
Test Plan with CookieManager Disabled
Try again to run the same test after disabling cookies manager and compare the results of both runs. If your cookies manager is disabled, then the user will not be logged in, and your sampler will fail due to the assertion.
Manually you can compare this behavior by enabling and disabling cookies in the real browser and try to log in.
With RedLine13, you can run a JMeter Load Test with your JMX script of any mobile application, web application, or API.