rails/rails — Issue #4990: Misleading documentation about multiple values in cookies
Author: MGPalmer
Created: 2012-02-10 15:01:30+00:00
State: open

I stumbled over this in action pack 3.2.1

In lib/action_dispatch/middleware/cookies.rb , it says:

# Examples for writing:
# ...
# # Assign an array of values to a cookie.
# cookies[:lat_lon] = [47.68, -122.37]
# ...
# Examples for reading:
# ...
# cookies[:lat_lon] # => [47.68, -122.37]

However, in my tests, values read from cookies are always strings. For example, I'm saving this:

cookies[:example] = ["example", Time.now.utc]

and when reading, I get:

"example&2012-02-10 11:12:45 UTC"

Answers about cookie handling in Rails always assume that you have to (de)serialize cookies yourself. Are the docs wrong ?