# addCookie not work

**URL:** <https://community.gatling.io/t/addcookie-not-work/2381>\
**Category:** Gatling (Open-Source)\
**Created:** [June 24, 2015, 10:24am UTC](https://community.gatling.io/t/addcookie-not-work/2381 "2015-06-24T10:24:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jilen\_nil](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@jilen\_nil](https://community.gatling.io/u/jilen_nil)\
**Post date:** [June 24, 2015, 10:24am UTC](https://community.gatling.io/t/addcookie-not-work/2381/1 "2015-06-24T10:24:03Z")

</div>

> Code

`

val scn = scenario(“TicketSimulation”)  
.exec(addCookie(Cookie(key, value)))  
.exec(http(“ticket\_get”).get(“some url”))

`

> Trace Info

`

---

<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:** [June 25, 2015, 5:24pm UTC](https://community.gatling.io/t/addcookie-not-work/2381/2 "2015-06-25T17:24:51Z")

</div>

Which version do you use?  
What do key and value look like?

---

<div class="post-metadata">

**Author:** ![Camilo\_Contreras](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Camilo\_Contreras](https://community.gatling.io/u/Camilo_Contreras)\
**Post date:** [October 9, 2015, 1:57pm UTC](https://community.gatling.io/t/addcookie-not-work/2381/3 "2015-10-09T13:57:00Z")

</div>

I’m using 2.0.3, and I’m having same issue:

```auto
.exec(addCookie(Cookie("stdo", f3188321-a82d-42ea-80e5-b0f57ff6e9fb")))

```

```auto
.exec(
  http("Request 1")
    .post(s"${theUrl}/api/")

```

```auto
)

```

The request doesn’t have the cookie I’m adding.

---

<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:** [October 9, 2015, 1:59pm UTC](https://community.gatling.io/t/addcookie-not-work/2381/4 "2015-10-09T13:59:50Z")

</div>

Quote from the [group rules/advices](https://groups.google.com/forum/#!forum/gatling):

_“Check that you’re not running an old version and that upgrading doesn’t fix your problem”_

---

<div class="post-metadata">

**Author:** ![Camilo\_Contreras](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Camilo\_Contreras](https://community.gatling.io/u/Camilo_Contreras)\
**Post date:** [October 9, 2015, 2:11pm UTC](https://community.gatling.io/t/addcookie-not-work/2381/5 "2015-10-09T14:11:46Z")

</div>

Well, I didn’t tell you the whole history. I’m not using Gatling directly, I’m using the SBT Gatling plugin, and I’m not able to use the latest version of Gatling/plugin, given that all of the projects we are working on, use Scala 2.10, and we found issues when trying to use the latest version of the plugin with Scala 2.10 ([https://groups.google.com/forum/#!topic/gatling/pSrJTs-ohQU](https://groups.google.com/forum/#!topic/gatling/pSrJTs-ohQU)).

So, we have to stick to Gatling 2.0.3, which has been working great so far, until this point, where I don’t know why the cookie is not set.

Thanks in advance for your help.

---

<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:** [October 9, 2015, 2:18pm UTC](https://community.gatling.io/t/addcookie-not-work/2381/6 "2015-10-09T14:18:47Z")

</div>

Except if you have strong dependencies to some internal libraries, you’d better move the Gatling stuff to a dedicated project/module where classpaths don’t clash. I’m 100% sure the issue you’re facing is fixed in 2.1.

Otherwise, sadly, as an open source project, we can’t afford maintaining many concurrent versions.

---

<div class="post-metadata">

**Author:** ![Camilo\_Contreras](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Camilo\_Contreras](https://community.gatling.io/u/Camilo_Contreras)\
**Post date:** [October 9, 2015, 6:04pm UTC](https://community.gatling.io/t/addcookie-not-work/2381/7 "2015-10-09T18:04:33Z")

</div>

Moving our simulations into a dedicated project contradicts the main reason why we are using the plugin: we want to be able of manage and do version control of our perforamnce test assets in conjunction with the code base; Anyway, I understand what you’re saying about the open source project.

Thanks for your help, and for answering so fast.

Cheers.

---

<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:** [October 9, 2015, 7:10pm UTC](https://community.gatling.io/t/addcookie-not-work/2381/8 "2015-10-09T19:10:42Z")

</div>

You could perfectly have a submodule in your project that uses a different Scala version.

---

<div class="post-metadata">

**Author:** ![Guillaume\_Lasnier](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@Guillaume\_Lasnier](https://community.gatling.io/u/Guillaume_Lasnier)\
**Post date:** [December 2, 2015, 10:19am UTC](https://community.gatling.io/t/addcookie-not-work/2381/9 "2015-12-02T10:19:44Z")

</div>

I had the same issue which I managed to fix by specifying a maxAge on the the cookie :

`  
val scn = scenario(“TicketSimulation”)  
.exec(addCookie(Cookie(key, value).withMaxAge(Int.MaxValue)))  
.exec(http(“ticket\_get”).get(“some url”))

`

---

<div class="post-metadata">

**Author:** ![Guillaume\_Lasnier](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@Guillaume\_Lasnier](https://community.gatling.io/u/Guillaume_Lasnier)\
**Post date:** [December 2, 2015, 10:26am UTC](https://community.gatling.io/t/addcookie-not-work/2381/10 "2015-12-02T10:26:14Z")

</div>

I also had to specify baseUrl on the http protocol. Should work if you specify the domain on cookie as well.
