# Disable automatic cookie handling?

**URL:** <https://community.gatling.io/t/disable-automatic-cookie-handling/5471>\
**Category:** Gatling (Open-Source)\
**Created:** [February 3, 2020, 2:50pm UTC](https://community.gatling.io/t/disable-automatic-cookie-handling/5471 "2020-02-03T14:50:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene\_Abramchuk](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@Eugene\_Abramchuk](https://community.gatling.io/u/Eugene_Abramchuk)\
**Post date:** [February 3, 2020, 2:50pm UTC](https://community.gatling.io/t/disable-automatic-cookie-handling/5471/1 "2020-02-03T14:50:16Z")

</div>

I want to have my own cookie handling.

Gatling 3.3

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [February 3, 2020, 3:20pm UTC](https://community.gatling.io/t/disable-automatic-cookie-handling/5471/2 "2020-02-03T15:20:25Z")

</div>

No, it’s not.  
Could you please explain how it would make sense to not have cookie handling working as specified in RFC6265?  
What’s your use case exactly?

---

<div class="post-metadata">

**Author:** ![Eugene\_Abramchuk](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@Eugene\_Abramchuk](https://community.gatling.io/u/Eugene_Abramchuk)\
**Post date:** [February 3, 2020, 3:58pm UTC](https://community.gatling.io/t/disable-automatic-cookie-handling/5471/3 "2020-02-03T15:58:10Z")

</div>

Hi Stéphane

Oh, I see. The wording on [https://gatling.io/docs/current/http/http\_helpers/](https://gatling.io/docs/current/http/http_helpers/) _“Cookie support is enabled by default”_ seemed to imply there is a way to turn it off.

In my scenario, I have to deal with two cookies I want to use intermittently. I can store both in the session and apply the one I need in any given particular HTTP call.

The default Gatling approach overwrites the first cookie with the second one (while my own approach retains both and I can inject them directly in headers), as shown below.  
Both cookies are issued by the same hostname, let’s say admin cookie and a user cookie:

```auto
override protected def setScenario(): ScenarioBuilder =
  scenario(getClass.getCanonicalName)
    .exec(postAdminLogin)
    .exec(postLogin)

```

```auto
    .exec(debugPrintSession)

```

> POST /admin/login HTTP/1.1

\< HTTP/1.1 302 Found  
\< Set-Cookie: PHPSESSID= **qvpq3dkqcjo88pfk9o4cm8eu71** ; expires=Wed, 04-Mar-2020 15:50:59 GMT; Max-Age=2592000; path=/

> POST /login HTTP/1.1  
> \< HTTP/1.1 302 Found

\< Set-Cookie: PHPSESSID= **pp9rhofq02m6uk476mooph6780** ; expires=Wed, 04-Mar-2020 15:50:59 GMT; Max-Age=2592000; path=/

Session(io.gatling.stacker.scenarios.Sandbox,1,1580745055935,Map(gatling.http.cache.baseUrl → [http://perfcomp](http://perfcomp), gatling.http.cache.dns → io.gatling.http.cache.DnsCacheSupport$$anon$1@e0654d5, **adminCookie → PHPSESSID=qvpq3dkqcjo88pfk9o4cm8eu71** , gatling.http.ssl.sslContexts → SslContexts(io.netty.handler.ssl.OpenSslClientContext@1fed69ad,None), gatling.http.referer → [http://perfcomp](http://perfcomp), **_gatling.http.cookies → CookieJar(Map(CookieKey(phpsessid,perfcomp,/) → StoredCookie(PHPSESSID=pp9rhofq02m6uk476mooph6780, path=/, maxAge=2592000s,true,true,1580745059203)))_**, **userCookie → PHPSESSID=pp9rhofq02m6uk476mooph6780** ),29,OK,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$387/1924990666@7e82439b)

Is there something I am missing?

Thanks!

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [February 3, 2020, 4:06pm UTC](https://community.gatling.io/t/disable-automatic-cookie-handling/5471/4 "2020-02-03T16:06:30Z")

</div>

Oh right, this sentence is indeed misleading, will fix.

Why don’t you Gatling cookie helpers to flush the cookie jar and add the cookie you need for the following request?

---

<div class="post-metadata">

**Author:** ![Eugene\_Abramchuk](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@Eugene\_Abramchuk](https://community.gatling.io/u/Eugene_Abramchuk)\
**Post date:** [February 3, 2020, 4:11pm UTC](https://community.gatling.io/t/disable-automatic-cookie-handling/5471/5 "2020-02-03T16:11:39Z")

</div>

This is a solution I am thinking of, I just wondered if there is a more graceful one.

Thanks!
