# Rails 1.2.2 cookies big headache!

**URL:** <https://www.ruby-forum.com/t/rails-1-2-2-cookies-big-headache/112321>\
**Category:** Rails\
**Created:** [August 17, 2007, 2:27pm UTC](https://www.ruby-forum.com/t/rails-1-2-2-cookies-big-headache/112321 "2007-08-17T14:27:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [August 17, 2007, 2:27pm UTC](https://www.ruby-forum.com/t/rails-1-2-2-cookies-big-headache/112321/1 "2007-08-17T14:27:07Z")

</div>

I am trying to write a cookie :

request.cookies[‘ad\_w1’] = {:value =\> “#{advertising.id}”, :expires =\>  
Time.now.utc+1.year}  
or

any other test

cookies[:user\_id] = { :value =\> ‘123’, :expires =\> Time.now + 1.hour}

but I continously get an error : TypeError: can’t modify frozen hash

something gets wrong but where ?

thanks for your lights …

* * *

note : discovered that …

Rails breaks the hash implementation that cookies appear, on the  
surface, to support.  
For whatever reason, symbol access of values doesnâ€™t work but string  
access does. Also, for whatever reason, the nil? method will not work  
but the empty? method does. Hopefully this saves somebody some  
frustration!

request.cookies[‘note’].value unless request.cookies[‘note’].empty?
