1
votes

According to Jmeter spec, "Each JMeter thread has its own "cookie storage area". So, it means I can't use one global (top-level) HTTP Cookie Manager to share cookies between different threads.

So, the only solution I know is to store cookies as properties and extract them at the beginning of each thread.

Q: Is there any other way to do the same without storing cookies in files/properties?

2

2 Answers

1
votes

As far as I know, there is no way to share cookies between all threads. So the solution you have tried (to manually set cookies and then extract them) should be the only one.

Here a user asked this question and has been answered this way by jMeter support:

No. JMeter threads are intended to represent independent users, so cookies and variables are local to a thread.

0
votes

If you need to share cookies between threads, not thread groups, as per Using the HTTP Cookie Manager in JMeter article:

Received Cookies can be stored as JMeter thread variables (versions of JMeter 2.3.2+ no longer do this by default).

To save cookies as variables, define the property CookieManager.save.cookies=true. The names of the cookies contain the prefix "COOKIE_" before they are stored (this avoids accidental corruption of local variables).

I hope you know how to work with the JMeter Variables.

The property can be set in 2 ways:

  1. As a command-line argument via -J key like:

    jmeter -JCookieManager.save.cookies=true 
    
  2. In user.properties file. In this case it will be permanent. Restart is required to pick to property up from file.