I want to clear the JMeter JsessionID variable at any time (on my demand).
I know there is a check box option in JMeter CookieManager named "Clear Cookie on each Iteration".
But it clears the session on each iteration while I want to clear it at any time in the iteration.
How can I do that in JMeter?
You can, just add post/pre process beanShell and with this code
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
for (int i=0;i<manager.getCookieCount();i++){
Cookie cookie = manager.get(i);
//remove a cookie
if (cookie.getName().equals("BAD_COOKIE")){
sampler.getCookieManager().remove(i);
}
}
Currently you cannot simply , particularly if you want to clear one particular cookie.
You should raise an enhancement request at JMeter Bugzilla giving precision on what you want to do.
I think a custom function would be a nice feature, see:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With