Shanmugam S
Shanmugam S

Reputation: 11

How to get httpcontext session value using jmeter

i can not get httpcontext session value through jmeter, how could i get session values from controller session through jmeter. can any one help!

variable: sessionid
regular expression: Set-Cookie:(,+?);
template: $1$

Upvotes: 1

Views: 578

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

If you need to do this using Regular Expression Extractor:

  1. Use Response Headers as the "Field to Check"
  2. Amend your regular expression to look like:

    Set-Cookie: (.*)
    

However this approach will give you full contents of the Set-Cookie header, not only the value but also domain, path, expires, secure, httponly attributes.

If you want to get the value of a single cookie into a JMeter Variable the easiest way is:

  1. Add the next line to user.properties file:

    CookieManager.save.cookies=true
    
  2. Restart JMeter to pick the property up
  3. Add HTTP Cookie Manager to your Test Plan
  4. That's it, now you can access any cookie value using the following pattern:

    ${COOKIE__your cookie name here}
    

    so if you have cookie named sessionid you can read its value as ${COOKIE__sessionid}

More information: HTTP Cookie Manager Advanced Usage - A Guide

Upvotes: 1

Related Questions