Kamal
Kamal

Reputation: 15

How to pass cookies value from one request body to another thread group request

I am new to JMeter and stuck in this issue, As we hit auth page two cookies have been created which are attached to all requests further. My few requests are failing as they are not getting these cookies in their request body. Kindly check the attached images cookies created at -32 need to be appended in the request -57. Please help me to pass these cookies to that request.

enter image description here

enter image description here

Upvotes: 0

Views: 667

Answers (1)

Dmitri T
Dmitri T

Reputation: 168147

As per Functions and Variables chapter of JMeter Documentation:

Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.

So JMeter's HTTP Cookie Manager stores cookies for each thread (virtual user) and they're not available in the other threads even in the same Thread Group and for some reason you have several Thread Groups.

The easiest solution is moving all the requests so they would be under the same Thread Group and placing your "login" samplers under the Once Only Controller


If for some reason you want to continue with your current test design (although it doesn't look good to me) you will need to:

  1. Extract cookies from the HTTP Cookie Manager for each thread (virtual user) in 1st Thread Group
  2. Convert them into JMeter Properties
  3. In 2nd Thread Group read the JMeter Properties containing the cookies and re-create them in the HTTP Cookie Manager

It can be accomplished using JSR223 Test Elements and Groovy language

Upvotes: 1

Related Questions