JMeter - How to capture a cookie value from log viewer and pass it as an input to another request?

97 Views Asked by At

I am using Jsr223 sampler and performing a login activity.

Using log.info in Jsr223 sampler, I am able to print a cookie value in JMeter log viewer.

I want to capture that value again from logviewer and pass it as an header manager input to another request.

2

There are 2 best solutions below

0
Dmitri T On
  • log.info(something) will print the value of something to JMeter log file
  • vars.put('someVariable', something) will save something into someVariable so you will be able to refer it as ${someVariable} in the HTTP Header Manager (or where required)

More information:

0
Alberto R On

You can store all cookies in variables by setting the CookieManager.save.cookies property in the jmeter.properties file as follows:

CookieManager.save.cookies=true

After restarting Jmeter you will be able to see and use all the cookies that are stored in variables. The name of the variables will be the cookie name preceded by COOKIE_.

To check all these variables, you can use a JMeter Debug Sampler.

For more information on these topics, please refer to the following resources: