Forum Discussion

atoth's avatar
atoth
Icon for Cirrus rankCirrus
Oct 26, 2019

Right way to modify a cookie?

I need to alter the domain of a pre-existing cookie. Lets say the cookie's name NewCookie. The obvious choice would to use

HTTP::cookie domain <name> [domain]

But description for that says

"NOTE: When setting a domain value, the attribute set by the F5 is “domain” instead of the RFC 6265 compliant “Domain” and is ignored by several browsers. If setting the “Domain” attribute is for the purpose of browser recognition, it is recommended that the header be modified directly instead of using the HTTP::cookie domain command. This behavior is by design."

So what would be the right way to do this?

If I need to change the NewCookie's domain to www.abc.com, what would be the right syntax?

I'm assuming it involves the HTTP::header syntax, but I'm sure exactly what.

1 Reply

  • If you are using BigIP v12 or later, use the

    HTTP::cookie attribute

    command.

    Please note: you will need to prepend a " " to the attribute being inserted until this is fixed in a future release.

    foreach cookie_name $cookie_names {
      HTTP::cookie attribute $cookie_name remove domain
      HTTP::cookie attribute $cookie_name insert " Domain" ".my_domain.org"
    }