# Set multiple cookies in the returned response?

**URL:** <https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387>\
**Category:** Support\
**Tags:** lambda-functions, netlify-newbie\
**Created:** [April 22, 2021, 1:05am UTC](https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387 "2021-04-22T01:05:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ekafyi](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ekafyi/32/2227_2.png) [@ekafyi](https://answers.netlify.com/u/ekafyi)\
**Post date:** [April 22, 2021, 1:05am UTC](https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387/1 "2021-04-22T01:05:54Z")

</div>

Hello,

I followed [this example to set cookie](https://github.com/DavidWells/netlify-functions-workshop/blob/master/lessons-code-complete/use-cases/4-setting-cookies/functions/set-cookie.js) in the lambda functions returned response and it works perfectly.

However, I have not figured out how to set _multiple cookies_.

I looked at [this thread](https://answers.netlify.com/t/multiple-set-cookie-headers-cause-netlify-lambda-to-throw-an-error/975/2) but did not quite get how to use `multiValueHeaders`. My code is the same as the first linked example.

Any help/pointer appreciated!

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [April 22, 2021, 7:52am UTC](https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387/2 "2021-04-22T07:52:48Z")

</div>

I haven’t tried this myself, but the way you set `multiValueHeaders` is like this:

```auto
return {
  statusCode: 200,
  multiValueHeaders: {
    "Set-Cookie": ["cookie1", "cookie2"]
  }
}

```

Does this work for you?

---

<div class="post-metadata">

**Author:** ![ekafyi](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ekafyi/32/2227_2.png) [@ekafyi](https://answers.netlify.com/u/ekafyi)\
**Post date:** [April 22, 2021, 4:51pm UTC](https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387/3 "2021-04-22T16:51:20Z")

</div>

It works perfectly on local dev.

But unfortunately when deployed, it returned this error: `error decoding lambda response: json: cannot unmarshal string into Go struct field .multiValueHeaders of type []interface {}`

My package.json only has this 1 command:

```auto
"scripts": {
  "build": "netlify-lambda build src/functions"
},

```

and my netlify.toml only has build settings

```auto
[build]
  command = "npm run build"
  publish = "build"
  functions = "functions"

```

Not sure what i did wrong here. 🤔

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [April 22, 2021, 4:55pm UTC](https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387/4 "2021-04-22T16:55:07Z")

</div>

I don’t think you need Netlify Lamda. When you build a website with functions, Netlify automatically builds the functions without you having to specify anything else apart from the functions directory in `netlify.toml`.

In any case, if you can provide a repo to test, that would be great.

---

<div class="post-metadata">

**Author:** ![ekafyi](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ekafyi/32/2227_2.png) [@ekafyi](https://answers.netlify.com/u/ekafyi)\
**Post date:** [April 22, 2021, 4:57pm UTC](https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387/5 "2021-04-22T16:57:40Z")

</div>

I use TS, need netlify-lambda to compile it. Sure, I’ll put up a repo tomorrow. Who knows I might discover I’d done something silly in the meantime! 😆

Thank you for your help so far!

---

<div class="post-metadata">

**Author:** ![ekafyi](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ekafyi/32/2227_2.png) [@ekafyi](https://answers.netlify.com/u/ekafyi)\
**Post date:** [April 22, 2021, 5:03pm UTC](https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387/6 "2021-04-22T17:03:40Z")

</div>

Solved.

`multiValueHeaders` can only contain the `Set-Cookie` property. Anything else goes in `headers` as usual.

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [April 22, 2021, 6:11pm UTC](https://answers.netlify.com/t/set-multiple-cookies-in-the-returned-response/36387/7 "2021-04-22T18:11:01Z")

</div>

Thank you for sharing, @ekafyi :netliconfetti: And @hrishikesh , thank you for these awesome debugging suggestions!
