# decode cookie in test scenario

**URL:** <https://community.gatling.io/t/decode-cookie-in-test-scenario/3865>\
**Category:** Gatling (Open-Source)\
**Created:** [August 3, 2017, 6:58am UTC](https://community.gatling.io/t/decode-cookie-in-test-scenario/3865 "2017-08-03T06:58:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommhb44](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@tommhb44](https://community.gatling.io/u/tommhb44)\
**Post date:** [August 3, 2017, 6:58am UTC](https://community.gatling.io/t/decode-cookie-in-test-scenario/3865/1 "2017-08-03T06:58:51Z")

</div>

Hello,

I have to decode a cookie before sent it to server. But this code does nothing and cookie stay encode :

`val scn = scenario("sc2") .exec(http("request_6") .post("/livelink/livelink.exe") .headers(headers_6) .formParam("func", "ll.login") .formParam("CurrentClientTime", "D/2017/7/31:14:10:50") .formParam("NextURL", "/livelink/livelink.exe?Redirect=1") .check(headerRegex("Set-Cookie", "LLCookie=(.*?);").find.saveAs("cookieRequest")) .resources(http("request_7") .get("/livelinksupport/style/screen.css") .headers(headers_1), http("request_8") .get("/livelinksupport/core/otfunc.css") .headers(headers_1), http("request_33") .get("/node/sncfrhome/shortcuts") .headers(Map("LLCookie" -> decode("${cookieRequest}"))), http("request_34")`

Do you have an idea ?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![tommhb44](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@tommhb44](https://community.gatling.io/u/tommhb44)\
**Post date:** [August 3, 2017, 8:58am UTC](https://community.gatling.io/t/decode-cookie-in-test-scenario/3865/2 "2017-08-03T08:58:21Z")

</div>

I find answer :

`  
def decode(s: String): String = URLDecoder.decode(s, “UTF-8”)  
…

`  
val scn = scenario(“sc2”)  
.exec(http(“request\_6”)  
.post("/livelink/livelink.exe")  
.headers(headers\_6)  
.formParam(“func”, “ll.login”)  
.formParam(“CurrentClientTime”, “D/2017/7/31:14:10:50”)  
.formParam(“NextURL”, “/livelink/livelink.exe?Redirect=1”)  
.check(headerRegex(“Set-Cookie”, “LLCookie=(.\*?);”).transform(token =\> decode(token)).saveAs(“cookieRequest”))  
.resources(http(“request\_7”)  
.get("/livelinksupport/style/screen.css")  
.headers(headers\_1),  
http(“request\_8”)  
.get("/livelinksupport/core/otfunc.css")  
.headers(headers\_1),  
http(“request\_33”)  
.get("/node/sncfrhome/shortcuts")  
.headers(Map(“LLCookie” → “${cookieRequest}”)),  
http(“request\_34”)  
…

`

`
