# Gatling 2: Example for saving the Cookie value from one exec and accessing from another exec

**URL:** <https://community.gatling.io/t/gatling-2-example-for-saving-the-cookie-value-from-one-exec-and-accessing-from-another-exec/1336>\
**Category:** Gatling (Open-Source)\
**Created:** [August 27, 2014, 8:46pm UTC](https://community.gatling.io/t/gatling-2-example-for-saving-the-cookie-value-from-one-exec-and-accessing-from-another-exec/1336 "2014-08-27T20:46:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayumi\_Liyanage](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Mayumi\_Liyanage](https://community.gatling.io/u/Mayumi_Liyanage)\
**Post date:** [August 27, 2014, 8:46pm UTC](https://community.gatling.io/t/gatling-2-example-for-saving-the-cookie-value-from-one-exec-and-accessing-from-another-exec/1336/1 "2014-08-27T20:46:12Z")

</div>

Hi, I am attempting to get Cookie value saved from one exec( ), and use it from the next exec( ).  
This is what I have for that:

scenario(“Homepage”)

.exec(http("/homepage")

.get("/")

.check(headerRegex(“Cookie”, “”“SSID=([^”]+)""").saveAs(“sid”)))

.exec(session =\> {println("\*\*\* " + session(“sid”).as[String] + " \*\*\*");session})

However it doesn’t seem to work. Could someone show an example on read in data from a cookie and pass in to the next exec?

Thanks

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [August 28, 2014, 8:03am UTC](https://community.gatling.io/t/gatling-2-example-for-saving-the-cookie-value-from-one-exec-and-accessing-from-another-exec/1336/2 "2014-08-28T08:03:13Z")

</div>

Hu Mayumi,

Cookie header coming from the server to the client is named “Set-Cookie” (“Set-Cookie2” also exists but it’s rarely used and is deprecated), “Cookie” is the one the client sends back to the client. 🙂

Cheers,

Stéphane
