Forum Discussion

MaxMedov's avatar
Icon for Cirrostratus rankCirrostratus
Sep 07, 2023

Duplicate "Set-Cookie" header in response

Hello, I have a duplicate Set-Cookie header in response and the client application didn't like it..
How can I remove one of the Set-Cookie headers and keep only one? For example the last one.
Thank you

2 Replies

  • Hi,

    Can you provide more information?

    Having multiple set-cookie is not something bad, actually it is often the case.

    Do you mean you have multiple set-cookie with the exact same cookie (same name, same domain, same path) and also with the same values? This would be strange 

    If it is the exact same cookie but the values are not the same, it would need further analysis because you would have to decide which one to keep, or it would be up to the browser to decide which one to use (generally the last one but I think that this is not guaranteed).

  • Hi ,Can you try to use an irule to remove the cookie for example:

    rule remove_cookie
    when HTTP_RESPONSE { HTTP::cookie remove "MYCOOKIE" } }
    In the case it remove both cookies you can try to added again with the irule but in this case is only going to add 1
    cookie and not a dupplicated

    The command to insert the cookie is:

    HTTP::cookie insert name <name> value <value> [path <path>] [domain <domain>] [version <0 | 1 | 2>]