Forum Discussion
Chris_Miller
Altostratus
Aug 09, 2010Rewrite Existing Client Cookie
Let's say a client has a cookie called "sample" with a value of "1" Can an F5 replace the value of the cookie on the client machine? I know it can insert a new cookie with the same name and different ...
Chris_Miller
Altostratus
Aug 09, 2010Posted By hoolio on 08/09/2010 02:49 PM
From RFC2109:
4.3.3 Cookie Management
If a user agent receives a Set-Cookie response header whose NAME is
the same as a pre-existing cookie, and whose Domain and Path
attribute values exactly (string) match those of a pre-existing
cookie, the new cookie supersedes the old. However, if the Set-
Cookie has a value for Max-Age of zero, the (old and new) cookie is
discarded. Otherwise cookies accumulate until they expire (resources
permitting), at which time they are discarded.
So you can overwrite an existing cookie value by setting a new cookie with the same name, domain and path as the prior cookie. You can do this in HTTP_RESPONSE using HTTP::cookie insert name < name > value < value >.
Aaron Thanks as always! I'm currently doing just this but have noticed my browser showing multiple cookies and as I use the "expire at browser close" default, I wasn't entirely sure how the F5 would handle a user with 2 "example" cookies. So, if I have an iRule like the following:
when HTTP_REQUEST {
if { [HTTP::cookie "example"] eq 1 } {
pool 1
} elseif { [HTTP::cookie "example"] eq 2 } {
pool 2 }
}
and the user has 2 "example" cookies, with the most recently inserted being "2", it would send the user to pool 2?Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects