I have the following setup:
Thread A
- Http Cookie Manager
- Login Page
Thread B
- Http Cookie Manager
- Page to hit
- Another page to hit
>
CookieManager
does not share cookies between threads. For some reason @ClarenceKlopfstein's method didn't work for me (jmeter 3.0). For some reason "${COOKIE_
didn't seemed to evaluate the string passed.
So, here's another solution to do a Login, and then pass the .ASPXAUTH
cookie. It should work without any configuration changes:
In a setUp Thread Group
(important):
BeanShell PostProcessor:
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = ctx.getCurrentSampler().getCookieManager();
Cookie cookie = manager.get(3); //Find the '.ASPXAUTH' cookie
log.info("Cookie:" + cookie);
props.put("MyCookie",cookie.getValue());
Then in a normal Thread Group:
BeanShell PreProcessor:
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
Cookie cookie = new Cookie(".ASPXAUTH",props.get("MyCookie"),"","/",false,0);
manager.add(cookie);