user1254330
user1254330

Reputation: 111

Cookie Manager of Apache JMeter doesn't add the cookie to POST request

I build up very simple test plan.

  1. Login: POST, a session cookie is returned.
  2. Get the state: GET, a user state is returned.
  3. Create a resource: POST, JSON body is supplied for the resource.

So my 'Test Plan' looks like:

The cookie generated by 'Login' is added to 'Get State' correctly.
But 'Create Resource' has NO cookie. I changed their order but it doesn't help. I used the default options firstly and changed some options but it also doesn't help.

Is it a bug of JMeter? or just POST http request is not able to have cookie?
Please give me any advice.

[SOLVED]
I noticed that it is related to the path, not the method.
You'd like to look at the domain of the cookie as well as the path. I mean, the path and the domain of a cookie could be defined in the server side through Set-Cookie header.

Upvotes: 11

Views: 34446

Answers (2)

Asif
Asif

Reputation: 1302

I had this turned on in my Spring Boot server which was causing the issue with CookieManager in jMeter:

server.servlet.session.cookie.secure=true

Removing this made the cookies flow ! Of course this is for localhost. For Production you may need this turned on.

Upvotes: 0

Eric Twilegar
Eric Twilegar

Reputation: 607

Another solution is to set CookieManager.check.cookies=false in jmeter.properties usually sitting besides the jmeter startup script in bin.

JMeter for some reasons thinks that you can't set the path=/something in a cookie if you are on http:/somesite/somethingelse. That is the path has to match the path your currently on.

I've never seen a browser enforce this limitation if it actually exists. I've seen and written several sites that use this technique to set a secure cookie and then forward someone say to /admin.

I wish this option was at least in the GUI so I didn't have to change the properties file. I think BlazeMeter is smart enough to turn off checking where flood.io is not. If it were up to me I'd just remove the code that checks this entirely. Why make the load tester any harder then it needs to be.

Upvotes: 6

Related Questions