1

When attempting to write/read cookies that have brackets in the name, it seems like Rails can't handle this. For example:

cookies["example[]"] = "value"

This causes the cookie name to be "example%5B%5D" instead of "example[]". Similarly, if I already have a cookie set with the name "example[]", then it seems like Rails is unable to properly delete it via a call cookies.delete "example[]" since the [ and ] characters are being encoded.

Anyone know how to fix this?

Matt Huggins
  • 81,398
  • 36
  • 149
  • 218

2 Answers2

0

Th rfc does not specify what all can be in the name of a cookie . All it says that the name needs to be text . I guess rails is encoding the text and hence the brackets are becoming %5B%5D . I think its best to avoid such characters in Cookies .

NM.
  • 1,909
  • 1
  • 13
  • 21
0

Looks like this can only be done by hacking the Rails core. Sucks that the Rails developers implemented it this way.

Community
  • 1
  • 1
Matt Huggins
  • 81,398
  • 36
  • 149
  • 218