I have a session variable and I want to use an If Controller to check if it is null and run a request to grab a new one if it is. I tried a few things...

"${session}" == "\${session}"
"${session}".length > 0

But none seem to work.

How do I check if a variable is set using an If Controller


You may try '${__javaScript(vars.get("session") != null)}

Please see the link for more detailed information.

| improve this answer | |

Since JMeter 4.0 you can use __isVarDefined() function which returns true if the JMeter Variable is defined (not null) and false otherwise


JMeter isVarDefined Demo

| improve this answer | |
  • can u show a sample usage ? , I have tried "${__isVarDefined(variableName}}" but not works. – Samet Baskıcı Feb 6 '19 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.