Forum Discussion
HyperSl4ck3r_16
Nimbostratus
Sep 11, 2014Getting cookie value and using switch
Greetings,
I am trying to write an iRule that provides the client with a cookie that we can use to dictate behavior and possibly redirect the user if needed. This is going to be used so we can ensur...
HyperSl4ck3r_16
Nimbostratus
Sep 12, 2014It looks like after some testing, simply insert/replace the cookie gets the desired result. Here is the finished rule that demonstrates it operates, and that the switches are working properly.
when HTTP_REQUEST {
if {not [HTTP::cookie exists Data_Locale]}
{set need_cookie 1}
set cookie_local [HTTP::cookie value Data_Locale]
switch $cookie_local
{
www1
{
set need_cookie 0
}
www2
{
set need_cookie 3
}
www3
{
set need_cookie 1
}
}
}
when HTTP_RESPONSE {
switch $need_cookie
{
0
{
HTTP::cookie insert name Data_Locale value www2
HTTP::cookie expires Data_Locale 1200 relative
}
1
{
HTTP::cookie insert name Data_Locale value www1
HTTP::cookie expires Data_Locale 1200 relative
}
3
{
HTTP::cookie insert name Data_Locale value www3
HTTP::cookie expires Data_Locale 1200 relative
}
}
}
What_Lies_Bene1
Cirrostratus
Sep 15, 2014Excellent.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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