0
votes

Issue 1: While recording scenario in jmeter, in the result's request body I am seeing all the cookie information. But when I run the script only few cookies are passed. I have added a cookie manager also, but its still the same.

Issue 2: I have added a regex extractor to extract a cookie value from the response header eg: Set Cookie: ASP.NET_SessionId=cg0kjo3gokjgdfjru2je2qzk; expression I used: ASP.NET_SessionId=(.+); variable name: aspsessionid

I have used the above variable in a header manager as below ASP.NET_SessionId = ${aspsessionid}

But its not passing the value, in the results request header it reads as ${aspsessionid}

Please help me solve these issues

1

1 Answers

0
votes

Make sure to:

  1. Use Response headers as the "Field to check"

  2. Provide $1$ as the "Template"

  3. If the cookie comes from a sub-sampler you need to tick Main sampler and sub-samples box

  4. Place Regular Expression extractor as the child of the request which returns the cookie you're looking for, otherwise the variable might be overwritten

    enter image description here

In general HTTP Cookie Manager should normally automatically handle the incoming cookies, if it doesn't - it might indicate a bug in your application like cookie is somehow invalid (expired, domain mismatch, etc.). If you're not worried in your application functional issues you can make HTTP Cookie Manager less restrictive by choosing more "relaxed" cookie policy, i.e. netscape

enter image description here

if this setting won't help you can add the next line to user.properties file (lives in "bin" folder of your JMeter installation)

CookieManager.check.cookies=false

and after JMeter restart the cookie manager will accept all the cookies no matter of expiration date, origin, etc.

More information: HTTP Cookie Manager Advanced Usage - A Guide