Function Apps | java

Abhay Chandramouli 716 Reputation points

I want to send Set-Cookie header as a function app response header. Function App is in Java.
I have been trying to send via .header(key,val) but the second one overrides the first
.header("Set-Cookie", "cookie1=das"+";HttpOnly")
.header("Set-Cookie", "cookie2=asd"+";HttpOnly")

only cookie2 appears

Please suggest a solution

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,019 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rudy Cortembert 1 Reputation point


    Your second statement overrides the first one.
    You should call .header("Set-Cookie"...) only once.

    Example :
    .header("Set-Cookie", "cookie1=das;cookie2=asd;HttpOnly")

    Side note: you should consider a StringBuilder to concatenate several cookies.

    Best Regards