Vairamuthu
Vairamuthu

Reputation: 578

How can i extraxt Session id and Xsrf token through cookies in jmeter

I have recorded script and run jmeter. the Session id and Xsrf tokens are passing request header cookies in browser cookies. but,session id is not passing in jmeter. So, connection closed error occurring.

How can i extract session id and xsrf token using regular expression extractor?

enter image description here

Upvotes: 0

Views: 2518

Answers (2)

Jackey Roy
Jackey Roy

Reputation: 11

You can use XPath extractor and enter "//input[@name='_csrf']/@value" to get the csrf token value and then enter desired reference name for example "csrf_token" and use the variable ${csrf_token} wherever necessary

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168147

  1. Add the next line to user.properties file (located in the "bin" folder of your JMeter installation)

    CookieManager.save.cookies=true
    
  2. Restart JMeter to pick the property up
  3. Add HTTP Cookie Manager to your Test Plan
  4. Now you should be able to refer cookie values as:

    • ${COOKIE_session} and
    • ${COOKIE__xsrf} where required

More information: Using the HTTP Cookie Manager in JMeter

Upvotes: 1

Related Questions