views:

29

answers:

2

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?

A: 

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
A: 

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

Matt Huggins