Forum Discussion

richard_77048's avatar
richard_77048
Icon for Nimbostratus rankNimbostratus
Jun 06, 2011

cookie not getting set using HTTP::cookie

Greetings,

 

 

I have a rule that is setting a cookie in an HTTP_REQUEST event before handing the request to the server. This is working on my development unit but the cookie fails to set on my production unit.

 

 

 

There are a couple of differences between development and production. Development is a BigIP 1500 running 9.4.7. Production is a BigIP 1600 9.4.8.

 

 

 

Here is what my rule is doing:

 

 

 

when HTTP_REQUEST {

 

if { not ( [HTTP::cookie language] equals $user_selected_language ) } {

 

HTTP::cookie language $user_selected_language

 

HTTP::cookie update_language 1

 

}

 

}

 

 

 

Again, this is working on 9.4.7 but fails to set the cookie "language" on 9.4.8. I have added logging lines to my rule and have verified that the $user_selected_language has some value in every case (so I left that part of the rule out). I tried checking for the existence of the cookie and doing an HTTP::cookie insert name "language" value "$user_selected_language" if the cookie didn't exists. That didn't do anything. If it is any help, the cookie doesn't exist.

 

 

 

I read through the 9.4.8 release notes and found something about a trailing semicolon getting inserted by the HTTP::cookie insert command. I didn't think that was happening in my case but I tried the workaround detailed in the release notes but that didn't help.

 

 

 

Any ideas? Any ideas of what to try next?

 

 

 

Richard

 

12 Replies

  • Well, I got my problem solved. I may go back to my original approach just because it does a little less processing but that is a project for another day.

     

     

    So, it turns out that I don't know as much as I could about HTTP cookies. Or I used to not know as much as I could; I know a little more now. I am sure it is not news to some of you that the path is important. I was not setting a path and the browser ended up with a bunch of "language" cookies. Once I set a path along with a value the new approach worked just fine. Now, why it worked in development in the first place, I don't know but QA signed off on the current rule so I am not going to worry about that today.

     

     

    I just wanted to put the resolution here in case it can help someone avoid the problems I had.

     

     

    Richard
  • The iRule you posted was using HTTP_REQUEST. So you were inserting cookies in the requests proxied to the pool members--not the response. Paths, domains and other cookie attributes are only included when the cookie is set in replies back to the client. These properties dictate how and when the server would like the client to send the cookies.

     

     

    I guess we should have clarified what the overall goal was before worrying too much about symptoms :) Thanks for posting the solution though. It is useful for future reference.

     

     

    Aaron