Forum Discussion

nsgguy245_16208's avatar
nsgguy245_16208
Icon for Nimbostratus rankNimbostratus
Jun 26, 2014

Forwarding BigIP Cookies on Redirect

I need to setup an iRule for a redirect, but I want the redirect to pass along the cookie information. Is that done by default or do I need to include configuration details to do this? Thanks...

 

6 Replies

  • You would want to use the HTTP::respond command and insert the "Set-Cookie" headers manually.

    HTTP::respond 302 Location "someplace-else" "Set-Cookie" "foo=bar;path=/" "Set-Cookie" "test=blah;path=/"
    

    Also consider that if you're redirecting to a different host, the browser will probably not honor these Set-Cookies.

  • Thanks for the feedback. Can setting up cookie persistence essentially accomplish the same thing?

     

  • Can setting up cookie persistence essentially accomplish the same thing?

     

    i do not think so because request does not reach server (pool member) yet.

     

  • Cookie persistence does in fact inject a cookie, but it's used for something completely different than what I suspect you're doing. Plus, as I mentioned earlier, if you're issuing a redirect to another server and/or site, the cookies that you inject in that redirect may not be honored by the remote site. Can you elaborate on what you're trying to do?

     

  • That dives a bit into the "HTTP State Management" RFCs and how cookies can be used across sites. In short, a cookie is natively host-specific. When a host, by name, sends a cookie to a client, the client should only ever return that cookie to the same host. Further, if a host attempts to send a cookie to a client, perhaps in a redirect, intended for another host, the client should ignore this cookie (for security reasons). The one caveat to this last condition is the "domain" attribute of a Set-Cookie header. A Set-Cookie header with a domain attribute tells the client that it can send that cookie back to any host that matches that domain (but must also be in the same domain as the cookie originator).

    So, let's say you have a site: host1.domain.com, and it wants to redirect users to host2.domain.com and send a cookie. The only way to do this is by setting a domain attribute in the Set-Cookie header with the value domain.com.

    HTTP::respond 302 Location "someplace-else" "Set-Cookie" "foo=bar;path=/" "Set-Cookie" "test=blah;path=/;domain=domain.com"
    
  • When that hit that website, they want the BigIP to do a redirect to another VIP (website) that we host on the same BigIP pair. They want the cookie information to be included as part of the redirect.

     

    who generates cookie? is it the first website user hits?

     

    does the first website do redirect? or it does not do redirect but you want bigip to do redirect after receiving response from it (the first website)?