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 value but am unsure of how to replace it.
- naladar_65658
Altostratus
I think something like this would allow you to change the cookie value. Sorry, I don't have a good way to test this out at the moment.when HTTP_REQUEST { Check if the cookie exists in request if { [HTTP::cookie exists "cookie-name"] } { Change cookie's value HTTP::cookie [value] [string] } }
- Chris_Miller
Altostratus
Posted By naladar on 08/09/2010 11:42 AM I think something like this would allow you to change the cookie value. Sorry, I don't have a good way to test this out at the moment.
Since this is in the HTTP_REQUEST event, this would just be replacing it from the F5 to the pool member, right?when HTTP_REQUEST { Check if the cookie exists in request if { [HTTP::cookie exists "cookie-name"] } { Change cookie's value HTTP::cookie [value] [string] } }
- naladar_65658
Altostratus
That is correct. To modify the cookie coming from the server going to the client you would have to use when HTTP_RESPONSE. Here is a good URL for a Wiki article talking about encrypting cookies, in which they describe how to change the values of the cookies. - Chris_Miller
Altostratus
Posted By naladar on 08/09/2010 12:19 PM - hoolio
Cirrostratus
From RFC2109: - Chris_Miller
Altostratus
Posted By hoolio on 08/09/2010 02:49 PM From RFC2109:
and the user has 2 "example" cookies, with the most recently inserted being "2", it would send the user to pool 2?when HTTP_REQUEST { if { [HTTP::cookie "example"] eq 1 } { pool 1 } elseif { [HTTP::cookie "example"] eq 2 } { pool 2 } }
- hoolio
Cirrostratus
Based on a little experience with this and reading the RFC, if you're setting the cookie correctly from LTM, it should overwrite the pre-existing cookie with the new value. If that's what you want to happen and it's not, I'd try investigating that issue further rather than try to determine which cookie in the request is the "correct" one. - Rami_307440
Nimbostratus
Hi Aaron, HTTP::cookie insert name < name > value < value >
That will insert a new cookie name and it will not over write the existing one.
~Rami
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