4
votes

I'm having a problem similar to the one in this post: JMeter; session cookie, but approached from a different angle.

The similarity is at the bottom of the post, where the OP writes:

How... can I set and submit a unique cookie for each user whose value is extracted from the first Response Header?

We're using JMeter for load testing, and need to have several users logged in to our email client at once. The way our website (and test plan) works is:

  • Enter username/ password, click Sign In.
  • Click Email.
  • Receive auth token (used for staying signed in to the email client) in a cookie.
  • Upon interaction with the email client (open a folder, mark an email as read, etc), send the auth token in the post body.

The problem is that the auth token is not getting stored as a value in such a way that it can be used in a POST request (and because the auth token is not sent as a cookie, we can't simply store it and send it with an HTTP Cookie Manager). The cookie is initially set like this:

AUTH_TOKEN=(long string of letters, numbers, and underscores); Domain=.ourdomain.net; Path=/

We've tried the following to extract the auth token value from the cookie:

  • Using a Regular Expression Extractor to extract the value from the response header of the "Click Email" step. We've tried two regular expressions; both simply cause JMeter to use the default auth token value when the test is run:
    • AUTH_TOKEN\=(\w+)\;
    • AUTH_TOKEN=([^;]+);
  • Defining the property "CookieManager.save.cookies=true" (as suggested by the user manual) and "CookieManager.check.cookies=false" (as suggested in this thread) in user.properties, then using "${COOKIE_AUTH_TOKEN}" in the post body.
    • With either or both of these in place, JMeter sets ${COOKIE_AUTH_TOKEN} as the auth token value in the post body.
    • We know that ${COOKIE_cookieName} is the correct format, as this has worked with other cookies that JMeter is storing.

I've read through a number of threads but none have dealt with this specific issue. I just started learning how to use JMeter a few weeks ago, so I'm not sure what to do here, and any help would be greatly appreciated. Thanks!

1
I'm trying to do the same thing, did you get it to work? Have you tried CookieManager.save.cookies=true?marko
@marko We actually ended up rewriting the entire thing, and it's now working. CookieManager.save.cookies=true saved the day, it was just a matter of sending the correct request to the server to get the correct cookie in the response.tjodox
Thanks for the followup! Good to know! It's difficult to configure JMeter sometimes...marko

1 Answers

6
votes

The problem was actually being caused by an incorrect request being sent to the server, to which it was then sending a blank response. Once we tore down and rewrote the entire test plan (what we were using was actually a modified version of another test plan) and had CookieManager.save.cookies=true in user.properties, we were able to use ${COOKIE_AUTH_TOKEN} and get the correct value.