2009年2月24日 星期二

cookies in rails

Rails Cookies Mangles the Hash Interface
cookies api
Session and cookie in rails


cookies 不是單純的 hash 而已, 簡單看這個例子就可以明白

So,
cookies[] gives you value from the incoming cookie.
cookies[]= sets value in the outgoing cookie.

The server needs to send the cookie to the browser and the browser has to return the cookie. Then you can read the value.

cookies[:its] = "1999"

*server response
*browser request

p cookies[:its]
#=> "1999"

沒有留言: