Forum Discussion
Bayan_El_Ameen1
Oct 30, 2011Nimbostratus
cookie insertion issue
Hello everyone,
I have been trying to do an iRule to redirect my traffic to a URL in case it's coming from a mobile device to a certain URL and I need to insert to a cookie once the user is redirected there so I don't have to redirect the user each time and get into an infinite redirection.
I have an issue that the URLs are dynamic and have like a hashing format after page load, so in case I request www.example.com/index.htm once I hit enter I am redirected to www.example.com/hsoo389la!pss something like this.
So, assuming that I need to redirect the users to www.example.com/mobile they will be redirected to the mobile app and then the URL will become something like www.example.com/os8903n9!d... which will recall the VS and the iRule and the redirection will reoccurr what will lead to an infinite redirection and I want to prevent that by using a cookie and that's what I tried but when I check using FF my cookies I don't see my cookie inserted. Note that I am using a tool on FF that let's me sending phone headers and it's working.
the iRule:
when HTTP_RESPONSE {
if { [class match [HTTP::header User-Agent] contains mobile_devices_list] } {
if { not [HTTP::cookie exists "mobilecookie"] } {
HTTP::cookie insert name mobilecookie value 1 path / domain www.example.com
HTTP::redirect "http://www.example.com./mobile"
}
}
}
- nitassEmployeei don't think there is user-agent http header in http response.
- just replace HTTP_RESPONSE with HTTP_REQUEST and your iRule should work (it looks good, according to your requirements).
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