Forum Discussion
Ted_Smith_11168
Nimbostratus
Aug 09, 2005help with cookie expiration in iRule
I have two iRules listed below. We are injecting a cookie on siteA, the redirecting to siteB. SiteB checks for value set in siteA. If it is there allow user access. If not go back to siteA and get value set.
We don't want people bookmarking and accessing siteb directly.
How can I specify a expiration time on the cookie we are setting through the iRule?
iRule set for www.companya.com VIP
when CLIENT_ACCEPTED {
set ckname www1
set ckvalue [IP::client_addr]
set ckdomain companya.com
set cookie [format "%s=%s; path=/; domain=%s" $ckname $ckvalue $ckdomain]
}
when HTTP_RESPONSE {
HTTP::respond 302 Location "https://www1.companya.com" "Set-Cookie" $cookie
}
iRule set for www1.companya.com VIP
when CLIENT_ACCEPTED {
set ckname www1
set ckvalue [IP::client_addr]
set ckdomain companya.com
}
when HTTP_REQUEST {
if {[HTTP::cookie exists $ckname]} {
pool UITShared
}
else {
HTTP::redirect "https://www.companya.com"
}
}
Thanks!
- The Set-Cookie header is specified in RFC 2109 - HTTP State Management Mechanism (Click here).
4.2.2 Set-Cookie Syntax The syntax for the Set-Cookie response header is set-cookie = "Set-Cookie:" cookies cookies = 1cookie cookie = NAME "=" VALUE *(";" cookie-av) NAME = attr VALUE = value cookie-av = "Comment" "=" value | "Domain" "=" value | "Max-Age" "=" value | "Path" "=" value | "Secure" | "Version" "=" 1*DIGIT
- Ted_Smith_11168
Nimbostratus
Thanks Joe, you are always very helpful (even when it is not a specific iRule question)! - unRuleY_95363Historic F5 AccountI think you might want your cookie domain to be ".companya.com".
- Ted_Smith_11168
Nimbostratus
I have made the change to the cookie domain, but I am still getting strange (unexplained and unwanted) results. - unRuleY_95363Historic F5 AccountMaybe you should post your current (desensitized) version of the rule with the uri stuff you added. Maybe there's something broken in that?!?
- Ted_Smith_11168
Nimbostratus
This is in an internal QA Environment:when CLIENT_ACCEPTED { set ckname uitaac1 set ckvalue [IP::client_addr] set ckdomain .allied.nwie.net set cookie [format "%s=%s; path=/; domain=%s" $ckname $ckvalue $ckdomain] } when HTTP_REQUEST { set uri [HTTP::uri] } when HTTP_RESPONSE { HTTP::respond 302 Location "https://uitaac1.allied.nwie.net$uri]" "Set-Cookie" $cookie }
when CLIENT_ACCEPTED { set ckname uitaac1 set ckvalue [IP::client_addr] set ckdomain .allied.nwie.net } when HTTP_REQUEST { set uri [HTTP::uri] if {[HTTP::cookie exists $ckname]} { pool UITShared } else { HTTP::redirect "https://uitaac.allied.nwie.net$uri" } }
- unRuleY_95363Historic F5 AccountEither this is a cut-n-paste error or perhaps your problem, but you have a closing square bracket ']' at the end of the uri in your first rule. Is that intended?
- Ted_Smith_11168
Nimbostratus
No it was not intended. Not sure how I missed it. Probably a typo from the 30 or so different things I have tried the last two days.
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