Ankit1492
Ankit1492

Reputation: 31

How to pass dynamic cookie in jmeter?

I have added HTTP Cookie Manager and HTTP Authorization Manager in Test Plan. When run the script following response message I have received

Response code: 401

Response message: UNAUTHORIZED

{"message":"Access is Denied","severity":"danger"}

This is my cookie

_ga=###; _gid=###; _gat=#; accessInfo={###}; userInfo={###}; 574ae166fc51fa5bdbd8beef725e77d7={###}; session=.###

But when run script only partial session is pass from my above cookie data through header request.

I also tried using regular expression but not getting response.

Can anyone suggest me how and where I can pass my cookies dynamically?

Upvotes: 1

Views: 2210

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

If the next request doesn't have all the cookies which you can see in the previous response Set-Cookie header most probably it indicates problem with the cookies.

You can check what exactly JMeter does with cookies by enabling debug logging for the HTTP Cookie Manager, in order to do this add the next line to log4j2.xml file (lives in "bin" folder of your JMeter installation:

<Logger name="org.apache.jmeter.protocol.http.control.CookieManager" level="debug" /> 

JMeter restart will be required to pick up the change.


Other things to try:

  1. Turn off JMeter built-in checks for cookies. In order to do this add the next line to user.properties file

    CookieManager.check.cookies=false
    
  2. Play with "Implementation" drop-down value, i.e. try choosing less restrictive implementation, for example netscape

    JMeter Cookie Manager Netscape

Upvotes: 1

Related Questions