sukria/Dancer — pull request #733 by bigpresh (2012-01-26 22:58:23+00:00)
Title: Fix GH-725 - multiple cookies problem

This should fix GH-725.

The issue, in a nutshell, is that you could set the same cookie name with multiple values, and it would result in multiple `Set-Cookie` headers for that same cookie, rather than sending the last-set value.

For instance:

cookie foo => 'foo1';
cookie bar => 'bar';
cookie foo => 'foo2'; # should override foo1

The response generated should include two `Set-Cookie` headers; one for `foo` with the value `foo2`, and one for `bar` with the value `bar`. Before this fix, though, you'd get two `Set-Cookie` headers for `foo`, which is incorrect.

This was highlighted by a recent change to the session handling code which caused the cookie to be set each time the session was accessed, in order to ensure that the expiry date is updated appropriately; that's a separate issue, but made this issue show up. (With this issue fixed, the problem @ilmari was seeing will be resolved, as only the last session cookie set will actually be returned.)

I'm pretty confident this is a sound fix, but I'd like extra eyeballs on it for approval.