Apache Bench – Setting Multiple Cookies

by Jason on October 12, 2011

Recently I’ve been doing some load testing on some web applications I’ve developed.

Reading the documentation they say you can set multiple cookies using multiple “-C” flags. However, this simply DID NOT WORK for me. Tried everything.

Since I’m sure others have run into this I’m offering an alternative.
Simply set the Cookies in a header.


ab -c 5 -n 100 -H “Cookie: PHPSESSID=115821732; another_cookie=asdfasdfasdf”

Happy load testing!


Had the same problem. Strange noone else seemed to run into this before. Do you know how to send multiple headers?
Thanks for posting this hint.

Cheers, Stefan

by Stefan on October 21, 2011 at 11:38 am. #

Yeah it’s weird, right?

Regarding the multiple headers I’m not sure… I haven’t yet had a situation where I needed to test multiple headers. I will probably have to do so with the testing I’m performing this week so if it comes up I’ll post another blog about it.

by Jason on October 22, 2011 at 6:50 am. #

Thanks for the post dude, you’re a legend!!!

by Konstantin on November 14, 2011 at 8:47 am. #

That’s gold Jerry! Gold!!!

Thanks a million.

by Scott Deagan on March 1, 2012 at 8:03 am. #

thank you

by xiaoshenge on March 22, 2012 at 9:51 pm. #

For multiple headers you can use the -H flag multiple times. So this command:

ab -c 10 -n 100 -H ‘host: example.com’ -H ‘Cookie:foo=bar;baz=qux’ http://www.example.com/

Will issue request headers like this:

GET / HTTP/1.0
host: example.com
User-Agent: ApacheBench/2.3
Accept: */*

by Jonathan on June 20, 2012 at 8:46 am. #

Thanks for this tip, did the job for me.

by Sanyam Yadav on October 31, 2012 at 5:53 am. #

Perfect – thank you!

by Nick Giles on August 22, 2013 at 5:32 am. #

You’re awesome !

by Marwen Abdesslem on November 22, 2015 at 2:54 pm. #

Leave your comment


Required. Not published.

If you have one.