Search code examples
jmeter-4.0

How to pass session id to cookie data using JMeter?


I'm new to JMeter and want to know how to pass session-id to all httpRequests.

I have tried with cookieManager and then HttpRequest is having session-id but response shows "session expired".


Solution

  • Cookie manager and Post Processor will solve the problem.

    For example-

    below opensrm is transaction controller

    Add HTTP Cookie Manager and add Post Processor in the request to extract the result as below.

    enter image description here

    Below is a Boundary extractor I used to extract the value of the session ID from the response.

    Refer this for Boundary Extractor

    enter image description here

    Now we will use this variable to initialize cookie in Cookie Manager

    enter image description here

    sessionID is a variable used to store extracted session id from the response in Boundary extractor.

    For how to use HTTP Cookie manager https://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager

    FYI: Cookie manager should be used where ever the session id is used in requests.