Setting Cookie in Jmeter

ThreadGroup
HttpRequest
BeanShell Pre Processor
CookieManager

This is what the Pre Processor should have
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
Cookie cookie = new Cookie(“<NAME>”,”<VALUE>”,”<HOST>”,”/”,false,0);
manager.add(cookie);

The only reason Im using a pre processor is Im not sure how else to get the
CookieManager , but I suppose there is a way . ideally I’d do this in a post
processor .

 

reference – http://jmeter.512774.n5.nabble.com/writnng-to-reading-to-cookies-td522380.html

Advertisements

2 Comments

Filed under JMeter

2 responses to “Setting Cookie in Jmeter

  1. Marian

    Hello,
    I would like to add something that doesn’t seem that obvious from the structure. The Beanshell PreProcessor HAS to be added as a CHILD of the HttpRequest. The preprocessor sets cookies per request. Otherwise thanks for the code 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s