Correlating the session ID

To correlate the session ID, you can use the following

  • a Regular Expression Extractor that saves the session ID into a local variable

  • a BeanShell Sampler that calls the "setProperty" function to set the local variable as a global property, so that it can be shared in all thread groups

In the case of PowerServer, the CreateSession request creates the session ID, therefore, you add a Regular Expression Extractor to the CreateSession request to get and save the session ID into a local variable.

To add a Regular Expression Extractor, right click on the CreateSession request and then select Add > Post Processors > Regular Expression Extractor.

Specify the Regular Expression Extractor like this.

  • Name of created variable: "session" or any name you prefer

  • Regular Expression: "sessionid":"(.+?)"

  • Template: $1$

  • Match No.: 1

The session ID will be saved to the "session" variable. You can invoke the local variable by typing ${session} in the requests (bodies and headers).

If you want to make the "session" variable a global property that can be accessed by all threads and thread groups, you can add a BeanShell Sampler or BeanShell PostProcessor to call the JMeter "setProperty" function. The "setProperty" function will set the "session" variable as a global property. the section called “Modifying the scripts” has instructions for how to add a BeanShell PostProcessor. This section will show how to add a BeanShell Sampler.

To add a BeanShell Sampler, right click on setUp Thread Group, and then select Add > Sampler > BeanShell Sampler.

  • Use the default name or input any name you prefer.

  • Input the following script:

    ${__setProperty(session,${session},)}

The "session" variable can be accessed as a JMeter global property.

Use the Search menu to search for all occurrences of "session" in all thread groups, and replace the static value of session ID with the global property ${__property(session,,)}.

For example,