Forum Discussion
mpfeifer_63884
Nimbostratus
Nov 30, 2009cookie expire
Hi.
We'd like to change the expiration date of a Cookie when a client comes in with a certain Useragent-string.
Normally our users just get the default Cookie which expires after the session.
So I thought, nothing easier than that:
when HTTP_REQUEST {
if {([HTTP::header User-Agent] contains "LEO")} {
HTTP::cookie expires Cookiename_Test 18144000
}
}
But this doesn't work. Actually it completely rejects the useragent. I tried different variations, by changing the Time-format, by using "persist" and all the attached options, but none did work.
Can someone tell me what is wrong with this iRule? I might just oversee something. Although the f5 isn't complaining about any syntactical issues.
thx.
Markus
19 Replies
- hoolio
Cirrostratus
Hi Markus,when HTTP_REQUEST { Check the User-Agent string if { [string tolower [HTTP::header User-Agent]] contains "leo" } { Set a variable to check the cookie in the response set check_cookie 1 } else { Set a variable to check the cookie in the response set check_cookie 0 } } when HTTP_RESPONSE { Check if cookie exists if { $check_cookie && [HTTP::cookie exists "Cookiename_Test"]}{ Update cookie expiry time HTTP::cookie expires Cookiename_Test 18144000 } }
- mpfeifer_63884
Nimbostratus
Hi Hoolio. - hoolio
Cirrostratus
Is it a cookie being set by LTM or by the web application? If the latter, is it a web app behind the VIP this iRule is added to? The iRule would only take effect once it's been added to the VIP and only affect the cookies being set after the iRule is added. - mpfeifer_63884
Nimbostratus
It is a cookie set by the LTM. It is not set explicitly without expiry time, but it is just a standard LTM Cookie which expires by closing the browser. - mpfeifer_63884
Nimbostratus
I found out, that in the Apache-logs the useragent-string looks like this: - hoolio
Cirrostratus
Can you try logging the value of the User-Agent header for all requests and add logging after the check for a User-Agent string containing leotrace? - mpfeifer_63884
Nimbostratus
Hi Aaron, as I am not able to do the logging as you asked me to do, I figured, that it also happens with any other User-Agent, for example "Galeon": - mpfeifer_63884
Nimbostratus
OK, in the meanwhile I tried a different approach, as I am afraid, that this might be a bug and I can't wait for that.when HTTP_RESPONSE { if { [HTTP::cookie exists "Cookie_Test"] and [HTTP::cookie value "1718485258.20480.0000"] } { HTTP::cookie expires Cookie_Test 18144000 }
- hoolio
Cirrostratus
Do you see the cookie being set, but being set with no expiry time? If not, can you explain the details of the failure scenario? - mpfeifer_63884
Nimbostratus
I get:
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