Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear JSESSIONID of each Thread(user) in Jmeter on demand

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?

like image 700
AsadYarKhan Avatar asked Oct 03 '12 11:10

AsadYarKhan


2 Answers

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);
    }
}
like image 187
Alaa Murad Avatar answered Oct 13 '22 12:10

Alaa Murad


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:

  • https://issues.apache.org/bugzilla/show_bug.cgi?id=53976
like image 35
UBIK LOAD PACK Avatar answered Oct 13 '22 11:10

UBIK LOAD PACK