HTTP Cookie Manager

JMeter – HTTP Cookie Manager

What is a Cookie?

By definition, cookies are text files that are stored for various information-tracking purposes on the client’s computer. In most cases, a cookie is added to the servlet response and stored in the browser’s cache. If a user subsequently submits a request, a cookie is automatically added to the request. As a result, the server identifies the user as the previous user. Therefore, if you do not manage the cookie with the JMeter HTTP Cookie Manager, the script registered by the secure application will fail during replay.

How does Apache JMeter handle cookies?

“HTTP Cookie Manager” is JMeter’s method of managing cookies. This configuration item allows you to emulate browser operations. The HTTP Cookie Manager works in two different ways:

1. Save and Send – Cookie Manager automatically saves all cookies returned in response to an HTTP request and uses those cookies for all subsequent searches on that specific website. This mimics how a real browser works. There is a separate “cookie storage area” for each JMeter thread. Another advantage of JMeter is the ability to store received cookies in a thread variable. Set the parameter “CookieManager.save.cookies=true” to save cookies as variables. It may be a good idea to prefix cookie names with “COOKIE_” before saving them to prevent accidental manipulation of local variables. Set the parameter “CookieManager.name.prefix=” (one or more spaces) to return to the default behavior. If enabled, the value of a cookie is ${COOKIE_TEST}.

2. Manually Add: A cookie can be manually added to the Cookie Manager. However, the cookie will be shared by all JMeter threads if you do this.

Cookie Manager Functions By changing the value of the cookie manager properties, JMeter allows you to change the default behavior and settings of the cookie manager. For example:

  • To keep cookies as variables, specify save.cookies=true/false.
  • To save cross-domain cookies for later use, set check.cookies=false.
  • name.prefix=true/false
  • delete_null_cookies=true/false

How to add ‘HTTP Cookie Manager’?

You can follow the following steps:

  1. Select the ‘Test Plan’ node
  2. Right-click on the ‘Test Plan’ node
  3. Mouse over ‘Add’
  4. Move your mouse over ‘Setting Item’
  5. Click on ‘HTTP Cookie Manager

What are the input fields of β€˜HTTP Cookie Manager’?

β€’ Name: to name the element

β€’ Leave any comments to chance.

β€’ Are cookies cleared after each iteration? The cookie is deleted at the beginning of the thread if this option is chosen. The GUI does not delete any of the cookies defined there.

β€’ Cookie cleanup control using Thread Group settings: using this option you can specify whether a new iteration involves the same user or a new one. It is linked to the “Same user each iteration” option in the Thread group.

β€’ Cookies policy: The cookie policy that will be used to manage cookies and options is:

Standard

standard-strict

ignore cookies

Netscape

default

rfc2109

rfc2965

best-match

compatibility

  • User-Defined Cookies: This option allows you to manually add cookies. This gives you the opportunity to use cookies that are encoded and used by all threads while the test is running. ‘Name’, ‘Value’, ‘Domain’, ‘Path’, and ‘Protected’ are all values you can add.
Scroll to Top