# Lost Cookie when Following Cached(?) Redirection

**URL:** <https://community.gatling.io/t/lost-cookie-when-following-cached-redirection/5538>\
**Category:** Gatling (Open-Source)\
**Created:** [March 12, 2020, 7:35pm UTC](https://community.gatling.io/t/lost-cookie-when-following-cached-redirection/5538 "2020-03-12T19:35:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gkallergis](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gkallergis/32/863_2.png) [@gkallergis](https://community.gatling.io/u/gkallergis)\
**Post date:** [March 12, 2020, 7:35pm UTC](https://community.gatling.io/t/lost-cookie-when-following-cached-redirection/5538/1 "2020-03-12T19:35:50Z")

</div>

Hello! 🙂

I’m new to Gatling and Scala and this time facing the following challenge.

I have a low-level action (function that returns HttpRequestBuilder) which I call twice in my scenario. The first time all works OK, but the second time it seems that when following a redirection the JSESSIONID cookie is not sent and the virtual is effectively logged out hence the test fails.

Here is the log of the first (successful) call. Some details have been removed:

`

18:17:35.127 [DEBUG] i.g.h.e.t.HttpTxExecutor - Sending request=Add Products to Basket uri=https://mywebsite.com/productPage.html: scenario=My Simulation, userId=1  
…  
HTTP request:  
POST [https://mywebsite.com/productPage.html](https://mywebsite.com/productPage.html)  
headers=  
…  
cookies=  
JSESSIONID=2b-0~D70931583B864103095D98B840D60423, path=/, secure, HTTPOnly  
formBody=  
CSRF\_TOKEN: 1c1cb057ebd50dc1466835a6745dba5c0bba9deac478d50e0b7e4ef0ebaced3942568251f8326e16c6427557b2a17f1bcc89c9de232d4f6c9f5b54845e8422c5  
…

---

<div class="post-metadata">

**Author:** ![gkallergis](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gkallergis/32/863_2.png) [@gkallergis](https://community.gatling.io/u/gkallergis)\
**Post date:** [March 12, 2020, 7:56pm UTC](https://community.gatling.io/t/lost-cookie-when-following-cached-redirection/5538/2 "2020-03-12T19:56:58Z")

</div>

Using disableCache at the http builder level allows the test to continue. I’ll leave this here though in case there is a bug in the caching of redirections.

---

<div class="post-metadata">

**Author:** ![gkallergis](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gkallergis/32/863_2.png) [@gkallergis](https://community.gatling.io/u/gkallergis)\
**Post date:** [March 12, 2020, 7:59pm UTC](https://community.gatling.io/t/lost-cookie-when-following-cached-redirection/5538/3 "2020-03-12T19:59:54Z")

</div>

[showBasket.html](https://www.google.com/url?q=https%3A%2F%2Fmywebsite.com%2FshowBasket.html&sa=D&sntz=1&usg=AFQjCNFUsxrAP6oFp8E4pmttBT2laMoveA) in the log is supposed to be myBasket.html. I made a mistake when coming up with random page names and stuff! 😃

---

<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:** [March 12, 2020, 9:04pm UTC](https://community.gatling.io/t/lost-cookie-when-following-cached-redirection/5538/4 "2020-03-12T21:04:46Z")

</div>

Is there any way for you to provide a reproducer so we can investigate?

---

<div class="post-metadata">

**Author:** ![gkallergis](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gkallergis/32/863_2.png) [@gkallergis](https://community.gatling.io/u/gkallergis)\
**Post date:** [March 18, 2020, 12:26pm UTC](https://community.gatling.io/t/lost-cookie-when-following-cached-redirection/5538/5 "2020-03-18T12:26:08Z")

</div>

Hello! I’ll try to create a standalone reproducer for it and let you know.

Thanks for your help,  
George

---

<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:** [March 18, 2020, 12:54pm UTC](https://community.gatling.io/t/lost-cookie-when-following-cached-redirection/5538/6 "2020-03-18T12:54:26Z")

</div>

Would be great! Thanks!
