Setting multiple cookies with a http.ResponseWriter

2,098 views
Skip to first unread message

Kai Backman

unread,
Mar 18, 2011, 4:11:08 PM3/18/11
to golang-nuts
I seem unable to figure out how to set multiple cookies on a
http.ResponseWriter. The canonical way seems to be to return multiple
"Set-Cookie" headers but the implementation in ResponseWriter uses a
map and overwrites any previous header values. Various sources claim
that using commas to separate cookie values isn't widely supported by
different browsers.

Am I missing something?

Kai

--
Kai Backman, programmer
http://tinkercad.com - solid modeling for artists and makers

Brad Fitzpatrick

unread,
Mar 18, 2011, 4:24:04 PM3/18/11
to Kai Backman, golang-nuts
This is fixed as of the last weekly release.

rw.Header().Add("Set-Cookie", "foo")
rw.Header().Add("Set-Cookie", "bar")

(Note: use Add instead of Set)

The latest "release"-tagged release doesn't have this yet.

Kai Backman

unread,
Mar 18, 2011, 4:30:40 PM3/18/11
to Brad Fitzpatrick, golang-nuts
On Fri, Mar 18, 2011 at 10:24 PM, Brad Fitzpatrick <brad...@golang.org> wrote:
> This is fixed as of the last weekly release.

Cool. I'll sit tight until it hits "release". Thanks!

Reply all
Reply to author
Forward
0 new messages