3

I'm trying to extract jsessionid from a sampler's response and reuse it for a third sampler. The sampler in between these two is an independent HTTP request which must not utilize any jsessionids.

I'm able to do this manually using a "Regular Expression Extractor" for the first sampler and requesting for jsessionid=${foobar} in the third sampler:

enter image description here

However, I'd like to accomplish this using the components specifically engineered for this purpose, like "Pre Processor → HTTP URL Re-writing Modifier" and etc.

How can we do URL rewriting for non-subsequent requests?


• Adding "HTTP URL Re-writing Modifier" to the third sampler doesn't work, because it will attempt to parse the response from the second sampler instead of the first one.

• Adding "HTTP URL Re-writing Modifier" to the second sampler doesn't work too, because while it is able to extract the jsessionid successfully, it uses that jsessionid for the second sampler instead of the third one.

2
  • Can you provide a screenshot of your problem so that we can see the order and arrangement of your samplers and assertions?
    – djangofan
    Dec 23, 2015 at 0:32
  • @djangofan, Ok, added screenshot.
    – Pacerier
    Jan 6, 2016 at 0:30

1 Answer 1

1

JSESSIONID is usually a cookie so you can use JMeter's HTTP Cookie Manager to refer its value.

  1. Add CookieManager.save.cookies=true line to user.properties file (it resides under /bin folder of your JMeter installation)
  2. Add HTTP Cookie Manager to your Test Plan
  3. Restart JMeter
  4. Refer "jsessionid" value as ${COOKIE_JSESSIONID} where required
3
  • 1
    Hi, yes the usual implementation for sessions is using cookies, but in this case it's using URL rewriting, not cookies. The server does not send Set-Cookie at all and the sessions work even if the browser has cookies disabled. As such, while step 4 works on the sever when it uses cookies, it instead uses the literal string ${COOKIE_JSESSIONID} (because there are no matching cookies returned) when the server uses HTTP rewriting.
    – Pacerier
    Sep 21, 2015 at 11:42
  • That sounds very unusual, and somewhat insecure for a site to implement sessions that way.
    – djangofan
    Dec 23, 2015 at 0:30
  • 1
    @djangofan, It's not unusual at all, and that's the only way to do sessions without cookies. It's the same as PHPSESSID with session.use_cookies = 0.
    – Pacerier
    Jan 6, 2016 at 0:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.