Setting multiple Cookies using ISAPI Filter [Answered]RSS

1 reply

Last post Oct 07, 2013 02:00 AM by Angie xu - MSFT

  • Setting multiple Cookies using ISAPI Filter

    Oct 01, 2013 08:30 AM|Paulo Pires|LINK

    I faced a problem to set multiple cookies in ISAPI filter. I want to add "HttpOnly" and "Secure" flag into all cookies.

    Firstly, I split the cookies (comma delimited) and add the flags, then combine them into one string, invoke "pResponse->SetHeader(pfc, "Set-Cookie:", szNewValue)" in the end. I can see on Fiddler that the first cookie got all the string concatenated and the others cookies were not changed. I'm using IIS 6.

    Example:

    In ASP Page

    <%
    Response.AddHeader "Set-Cookie", "Cookie1=conteudo1;Expires=Thu, 10 Oct 2013 12:24:57 GMT; Path=/certificados;"
    Response.AddHeader "Set-Cookie", "Cookie2=conteudo2;Expires=Thu, 10 Oct 2013 12:24:57 GMT; Path=/certificados; HttpOnly"
    Response.AddHeader "Set-Cookie", "Cookie3=conteudo3;Expires=Thu, 10 Oct 2013 12:24:57 GMT; Path=/certificados; HttpOnly; Secure"
    Response.AddHeader "Set-Cookie", "Cookie4=conteudo4; Path=/certificados;"
    Response.AddHeader "Set-Cookie", "Cookie5=conteudo5; Path=/certificados; HttpOnly"
    Response.AddHeader "Set-Cookie", "Cookie6=conteudo6; Path=/certificados; HttpOnly; Secure"
    %>


    Response: (Fiddler)

    Set-Cookie: Cookie2=conteudo2;Expires=Thu, 10 Oct 2013 12:24:57 GMT; Path=/certificados; HttpOnly
    Set-Cookie: Cookie3=conteudo3;Expires=Thu, 10 Oct 2013 12:24:57 GMT; Path=/certificados; HttpOnly; Secure
    Set-Cookie: Cookie4=conteudo4; Path=/certificados;
    Set-Cookie: Cookie5=conteudo5; Path=/certificados; HttpOnly
    Set-Cookie: Cookie6=conteudo6; Path=/certificados; HttpOnly; Secure
    Set-Cookie: ASPSESSIONIDCCDDQQCA=BLNLIMFBBIFADMEHANNNBONI; path=/
    Set-Cookie: Cookie1=conteudo1;Expires=Thu, 10 Oct 2013 12:24:57 GMT; Path=/certificados; HttpOnly; Secure,Cookie2=conteudo2;Expires=Thu, 10 Oct 2013 12:24:57 GMT; Path=/certificados; HttpOnly; Secure,Cookie3=conteudo3;Expires=Thu, 10 Oct 2013 12:24:57 GMT; Path=/certificados; HttpOnly; Secure,Cookie4=conteudo4; Path=/certificados; HttpOnly; Secure,Cookie5=conteudo5; Path=/certificados; HttpOnly; Secure,Cookie6=conteudo6; Path=/certificados; HttpOnly; Secure,ASPSESSIONIDCCDDQQCA=BLNLIMFBBIFADMEHANNNBONI; path=/; HttpOnly; Secure
    

    Thanks in advance

    cookie isapi iis6

  • Re: Setting multiple Cookies using ISAPI Filter

    Oct 07, 2013 02:00 AM|Angie xu - MSFT|LINK

    Hi Paulo

    Paulo Pires

    I can see on Fiddler that the first cookie got all the string concatenated and the others cookies were not changed. I'm using IIS 6.

    For this issue, I'm afraid that it can only set one cookie at a time. You can also take a look at this discussion below,

    # Cannot set multiple cookies with one CookieEncoder

    Regards

     

    cookie isapi iis6

    Angie xu

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.