locked
Setting multiple Cookies using ISAPI Filter RRS feed

  • Question

  • User-2053220893 posted

    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

    Tuesday, October 1, 2013 8:30 AM

Answers

  • User-823319154 posted

    Hi Paulo

    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

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Monday, October 7, 2013 2:00 AM