# Save Gatling request response to use it across requests

**URL:** <https://community.gatling.io/t/save-gatling-request-response-to-use-it-across-requests/7711>\
**Category:** Gatling (Open-Source)\
**Created:** [March 14, 2023, 3:06pm UTC](https://community.gatling.io/t/save-gatling-request-response-to-use-it-across-requests/7711 "2023-03-14T15:06:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![damodharj](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@damodharj](https://community.gatling.io/u/damodharj)\
**Post date:** [March 14, 2023, 3:06pm UTC](https://community.gatling.io/t/save-gatling-request-response-to-use-it-across-requests/7711/1 "2023-03-14T15:06:58Z")

</div>

I have written gatling API request inside a function. That request will returns the token which I want to return from function so that it can be used across various request. Can someone please help here.

---

<div class="post-metadata">

**Author:** ![shoaib42](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/shoaib42/32/844_2.png) [@shoaib42](https://community.gatling.io/u/shoaib42)\
**Post date:** [March 14, 2023, 5:02pm UTC](https://community.gatling.io/t/save-gatling-request-response-to-use-it-across-requests/7711/2 "2023-03-14T17:02:33Z")

</div>

Can you share some samples here, the more verbose the better answers you get.

- why can’t you store the token in the session, and use it across all other requests

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [March 14, 2023, 7:38pm UTC](https://community.gatling.io/t/save-gatling-request-response-to-use-it-across-requests/7711/3 "2023-03-14T19:38:44Z")

</div>

Hello @damodharj,

As @shoaib42 wrote, the best way to handle that is to use [session](https://gatling.io/docs/gatling/reference/current/core/session/) variables with a [`saveAs`](https://gatling.io/docs/gatling/reference/current/core/check/#saveas) on the check you use to extract your token.

If there is no enough explanation for you, please provide your current code and what you tested.  
A full reproducer will help anyone in the forum to help you.

Cheers!

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [April 13, 2023, 7:38pm UTC](https://community.gatling.io/t/save-gatling-request-response-to-use-it-across-requests/7711/4 "2023-04-13T19:38:46Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
