How to add multiple cookies to Response in WCF / REST service

Posted by Sumtraveller on Stack Overflow See other posts from Stack Overflow or by Sumtraveller
Published on 2010-03-14T22:21:41Z Indexed on 2010/03/14 22:25 UTC
Read the original article Hit count: 995

Filed under:
|
|

I have access to WebOperationContext and can add one cookie by doing this:

 WebOperationContext.Current.OutgoingResponse.Headers.Add("Set-Cookie: foo_a=bar_a");

However if I call that several times, e.g.:

 WebOperationContext.Current.OutgoingResponse.Headers.Add("Set-Cookie: foo_a=bar_a");
 WebOperationContext.Current.OutgoingResponse.Headers.Add("Set-Cookie: foo_b=bar_b");

I should get the following in my header (2 cookies):

Set-Cookie: foo_a=bar_a
Set-Cookie: foo_b=bar_b

But instead get:

Set-Cookie: foo_a=bar_a, foo_b=bar_b

How do I set multiple cookies? Thx

© Stack Overflow or respective owner

Related posts about wcf

Related posts about cookies