Session specific variables

I am fairly new to Gatling and I started writing a simulation for our system that requires user specific variables in creating and posting a form. I tried finding out how to cache these variables e.g. at request_6 I have a citizenId that I need to keep throughout the whole app but I think the syntax might have been updated.

The code (with some lines censored) is this and I need the last variable saved and re-used through the rest of the requests that follows.

    .formParam("Param", param)
    .formParam("FullName", "fullName")

The “citizenId” is something I need to cache from the site and re-use.

To further add to this I have lines after that require these variables and Id’s to be able to continue the Digital Claim.


Hi @ObiKanTV,

Welcome aboard!

You seem to already know how to use the session api. So I’m not sure what is your question.

Ensure that your "request_7" is called after "request_6" in your scenario and it should be good.
Ensure that your "request_6" correctly works (ie no failure) because of your jsonPath (citizinId vs citizenId perhaps?)

Does that help?


It might be that these didn’t work because of something happening earlier in the simulation rather than being this snippet I originally was troubleshooting.

Does the Line: .check(jsonPath(“$.digitalClaimId”).saveAs(“digitalClaimsId”))
save the digitalClaimsId for the rest of the below requests or do I need to cache this repeatedly?

I’m not sure to understand your last question.
If you have only one value to store, or you only want the last value, you don’t need to (and I don’t see how to) saveAs in below requests.
But the exec must be executed by the same virtual user (described in the same scenario, request_6 executed before request_7)

For better explanation, you really should send a SSCCE (see How to Ask a Question)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.