Forum Discussion

Bayan_El_Ameen1's avatar
Icon for Nimbostratus rankNimbostratus
Oct 30, 2011

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 once I hit enter I am redirected to!pss something like this.

So, assuming that I need to redirect the users to they will be redirected to the mobile app and then the URL will become something like!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:

    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
            HTTP::redirect ""

2 Replies

  • i don't think there is user-agent http header in http response.



    by the way, why won't you redirection only when request is coming from mobile device (by checking user-agent) to / since next request which is /mobile or /hash_value would not trigger the redirection again?



    or is there anything i missed?
  • just replace HTTP_RESPONSE with HTTP_REQUEST and your iRule should work (it looks good, according to your requirements).





    Kurt Knochner